Skip to content

Instantly share code, notes, and snippets.

@benboecker
Last active December 11, 2020 21:30
Show Gist options
  • Save benboecker/80cd1da6a7718107bf17dd55b52047d7 to your computer and use it in GitHub Desktop.
Save benboecker/80cd1da6a7718107bf17dd55b52047d7 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Takes filename as parameter.
file=$1
if [ -z "$file" ]
then
echo "<png_file> argument not specified."
exit 1
elif [ ! -f "$file" ]
then
echo "$file was not found."
exit 1
fi
iconSet="AppIcon.appiconset"
rm -rf $iconSet
mkdir -p $iconSet
# Icon 20
convert $file -resize 20x20 $iconSet/[email protected]
convert $file -resize 40x40 $iconSet/[email protected]
convert $file -resize 60x60 $iconSet/[email protected]
# Icon 29
convert $file -resize 29x29 $iconSet/[email protected]
convert $file -resize 58x58 $iconSet/[email protected]
convert $file -resize 87x87 $iconSet/[email protected]
# Icon 40
convert $file -resize 40x40 $iconSet/[email protected]
convert $file -resize 80x80 $iconSet/[email protected]
convert $file -resize 120x120 $iconSet/[email protected]
# Icon 50
convert $file -resize 50x50 $iconSet/[email protected]
convert $file -resize 100x100 $iconSet/[email protected]
# Icon 57
convert $file -resize 57x57 $iconSet/[email protected]
convert $file -resize 114x114 $iconSet/[email protected]
# Icon 60
convert $file -resize 120x120 $iconSet/[email protected]
convert $file -resize 180x180 $iconSet/[email protected]
# Icon 72
convert $file -resize 72x72 $iconSet/[email protected]
convert $file -resize 144x144 $iconSet/[email protected]
# Icon 76
convert $file -resize 76x76 $iconSet/[email protected]
convert $file -resize 152x152 $iconSet/[email protected]
# Icon 83.5
convert $file -resize 167x167 $iconSet/[email protected]
# Icon marketing
cp $file $iconSet/ios-marketing.png
json='{ "info" : { "version" : 1, "author" : "xcode" }, "images" : [ { "size" : "40x40", "idiom" : "ipad", "filename" : "[email protected]", "scale" : "1x" }, { "size" : "40x40", "idiom" : "ipad", "filename" : "[email protected]", "scale" : "2x" }, { "size" : "60x60", "idiom" : "iphone", "filename" : "[email protected]", "scale" : "2x" }, { "size" : "72x72", "idiom" : "ipad", "filename" : "[email protected]", "scale" : "1x" }, { "size" : "72x72", "idiom" : "ipad", "filename" : "[email protected]", "scale" : "2x" }, { "size" : "76x76", "idiom" : "ipad", "filename" : "[email protected]", "scale" : "1x" }, { "size" : "76x76", "idiom" : "ipad", "filename" : "[email protected]", "scale" : "2x" }, { "size" : "50x50", "idiom" : "ipad", "filename" : "[email protected]", "scale" : "1x" }, { "size" : "50x50", "idiom" : "ipad", "filename" : "[email protected]", "scale" : "2x" }, { "size" : "29x29", "idiom" : "iphone", "filename" : "[email protected]", "scale" : "1x" }, { "size" : "29x29", "idiom" : "iphone", "filename" : "[email protected]", "scale" : "2x" }, { "size" : "57x57", "idiom" : "iphone", "filename" : "[email protected]", "scale" : "1x" }, { "size" : "57x57", "idiom" : "iphone", "filename" : "[email protected]", "scale" : "2x" }, { "size" : "29x29", "idiom" : "iphone", "filename" : "[email protected]", "scale" : "3x" }, { "size" : "40x40", "idiom" : "iphone", "filename" : "[email protected]", "scale" : "3x" }, { "size" : "60x60", "idiom" : "iphone", "filename" : "[email protected]", "scale" : "3x" }, { "size" : "40x40", "idiom" : "iphone", "filename" : "[email protected]", "scale" : "2x" }, { "size" : "29x29", "idiom" : "ipad", "filename" : "[email protected]", "scale" : "1x" }, { "size" : "29x29", "idiom" : "ipad", "filename" : "[email protected]", "scale" : "2x" }, { "size" : "83.5x83.5", "idiom" : "ipad", "filename" : "[email protected]", "scale" : "2x" }, { "size" : "20x20", "idiom" : "iphone", "filename" : "[email protected]", "scale" : "2x" }, { "size" : "20x20", "idiom" : "iphone", "filename" : "[email protected]", "scale" : "3x" }, { "size" : "20x20", "idiom" : "ipad", "filename" : "[email protected]", "scale" : "1x" }, { "size" : "20x20", "idiom" : "ipad", "filename" : "[email protected]", "scale" : "2x" }, { "size" : "1024x1024", "idiom" : "ios-marketing", "filename" : "ios-marketing.png", "scale" : "1x" } ] }'
echo $json > $iconSet/Contents.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment