Skip to content

Instantly share code, notes, and snippets.

@munho
Forked from kukat/imageset.sh
Created May 16, 2016 23:36
Show Gist options
  • Save munho/3cc2e6a80f27a3b2bde24da69b4975c1 to your computer and use it in GitHub Desktop.
Save munho/3cc2e6a80f27a3b2bde24da69b4975c1 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment