Bash script for creating iOS & Android icons for OS X

Hi, while I developed Senile Bird, I automated some parts of the process, such as scaling icons properly for iOS and Android devices. Since for iOS 6 and iOS 7 icons there is a minor difference on the edge curvature, I put them as separate parameters.
PNG file should have at least size of 192px, so that no quality is lost in the process. Also this assumes that you’re using Mac OS X since sips command only exists on Mac OS X’s.

[code language=”bash”]
#!/bin/bash

if [ $# -ne 3 ]
then
echo "Usage: create_icons.sh <ios6_icon.png> <ios7_icon.png> <android_icon.png>"
exit 1
fi

f=$(pwd)
mkdir -p ios android
sips –resampleWidth 57 "${f}/${1}" –out "${f}/ios/Icon-57.png"
sips –resampleWidth 72 "${f}/${1}" –out "${f}/ios/Icon-72.png"
sips –resampleWidth 76 "${f}/${2}" –out "${f}/ios/Icon-76.png"
sips –resampleWidth 114 "${f}/${1}" –out "${f}/ios/Icon-114.png"
sips –resampleWidth 120 "${f}/${2}" –out "${f}/ios/Icon-120.png"
sips –resampleWidth 144 "${f}/${1}" –out "${f}/ios/Icon-144.png"
sips –resampleWidth 152 "${f}/${2}" –out "${f}/ios/Icon-152.png"

mkdir -p android/drawable-ldpi
sips –resampleWidth 36 "${f}/${3}" –out "${f}/android/drawable-ldpi/icon.png"

mkdir -p android/drawable-mdpi
sips –resampleWidth 48 "${f}/${3}" –out "${f}/android/drawable-mdpi/icon.png"

mkdir -p android/drawable-hdpi
sips –resampleWidth 72 "${f}/${3}" –out "${f}/android/drawable-hdpi/icon.png"

mkdir -p android/drawable-xhdpi
sips –resampleWidth 96 "${f}/${3}" –out "${f}/android/drawable-xhdpi/icon.png"

mkdir -p android/drawable-xxhdpi
sips –resampleWidth 144 "${f}/${3}" –out "${f}/android/drawable-xxhdpi/icon.png"

mkdir -p android/drawable-xxxhdpi
sips –resampleWidth 192 "${f}/${3}" –out "${f}/android/drawable-xxxhdpi/icon.png"
[/code]
Feel free to give feedback, so we can make this better. 🙂

Leave a Comment