Created
April 2, 2014 10:50
-
-
Save kukat/9931854 to your computer and use it in GitHub Desktop.
Xcode 5 imageset generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
SOURCE_PATH=$1 | |
for f in "$SOURCE_PATH"/*.png; do | |
fullname=$(basename "$f") | |
filename=${fullname%@2x.*} | |
imageset="$SOURCE_PATH"/"$filename".imageset | |
jsonfile="$imageset"/Contents.json | |
echo "Creating folder: $imageset" | |
mkdir "$imageset" | |
echo "Copy image to .imageset" | |
cp "$f" "$imageset"/ | |
echo "Creating JSON file: $jsonfile" | |
touch "$jsonfile" | |
echo "Write JSON file... Done." | |
cat <<- EOF > "$jsonfile" | |
{ | |
"images" : [ | |
{ | |
"idiom" : "universal", | |
"scale" : "1x" | |
}, | |
{ | |
"idiom" : "universal", | |
"scale" : "2x", | |
"filename" : "$fullname" | |
} | |
], | |
"info" : { | |
"version" : 1, | |
"author" : "xcode" | |
} | |
} | |
EOF | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
sh imageset.sh /path/to/your_2x_png_folder