Thomas Denney

Creating iOS app icons with a shell script

One of the more annoying parts of working on iOS project is generating all of the appropriate artwork - there are up to 13 different images that you have to create just for the app icon. Several apps exist for this, however I figured a simpler solution would be to have a simple shell script:

#!/bin/sh

ITUNES_ARTWORK="$1"
FOLDER=$(dirname "$ITUNES_ARTWORK")

sips -z 57 57 "$ITUNES_ARTWORK" --out "${FOLDER}/Icon.png"
sips -z 114 114 "$ITUNES_ARTWORK" --out "${FOLDER}/Icon@2x.png"
sips -z 120 120 "$ITUNES_ARTWORK" --out "${FOLDER}/Icon-60@2x.png"
sips -z 29 29 "$ITUNES_ARTWORK" --out "${FOLDER}/Icon-Small.png"
sips -z 58 58 "$ITUNES_ARTWORK" --out "${FOLDER}/Icon-Small@2x.png"
sips -z 40 40 "$ITUNES_ARTWORK" --out "${FOLDER}/Icon-Small-40.png"
sips -z 80 80 "$ITUNES_ARTWORK" --out "${FOLDER}/Icon-Small-40@2x.png"
sips -z 50 50 "$ITUNES_ARTWORK" --out "${FOLDER}/Icon-Small-50.png"
sips -z 100 100 "$ITUNES_ARTWORK" --out "${FOLDER}/Icon-Small-50@2x.png"
sips -z 72 72 "$ITUNES_ARTWORK" --out "${FOLDER}/Icon-72.png"
sips -z 144 144 "$ITUNES_ARTWORK" --out "${FOLDER}/Icon-72@2x.png"
sips -z 76 76 "$ITUNES_ARTWORK" --out "${FOLDER}/Icon-76.png"
sips -z 152 152 "$ITUNES_ARTWORK" --out "${FOLDER}/Icon-76@2x.png"

Here’s what you need to do to set it up:

  • Save the above into a file in your home directory called icongenerator.sh (it is imperative that it is in your home directory)
  • Open up terminal and execute ‘chmod +x icongenerator.sh’
  • Execute ‘./icongenerator.sh path/to/iTunesArtwork’
  • The script will then create the new image files

In case you haven’t come across it before, sips is a really simple way of quickly resizing images on the command line on OSX.