Skip to content

Instantly share code, notes, and snippets.

@kukat
Created April 2, 2014 10:50
Show Gist options
  • Save kukat/9931854 to your computer and use it in GitHub Desktop.
Save kukat/9931854 to your computer and use it in GitHub Desktop.
Xcode 5 imageset generator
#!/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
@kukat
Copy link
Author

kukat commented Apr 2, 2014

Usage:
sh imageset.sh /path/to/your_2x_png_folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment