Last active
December 23, 2015 13:56
-
-
Save warrenburton/6183392 to your computer and use it in GitHub Desktop.
Batch script for creating iOS icon sizes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Usage: | |
#generate_icons.sh /path/to/mastericon.png | |
#Assumes your master icon image is larger than 180px by 180px at least | |
i=0 | |
sizes=(76 72 50 40 29 57 60 167) | |
iconset=generated-icons | |
echo working into on $iconset | |
if [ -d $iconset ]; then | |
rm -rf $iconset | |
fi | |
mkdir -p $iconset | |
base=iconbase.png | |
cp $1 $iconset/$base | |
echo working on $1 | |
while [ $i -lt ${#sizes[@]} ]; do | |
nextsize=${sizes[$i]} | |
nextsize2x=$((2*nextsize)) | |
nextsize3x=$((3*nextsize)) | |
nextname=icon-$nextsize.png | |
nextname2x=icon-$nextsize@2x.png | |
nextname3x=icon-$nextsize@3x.png | |
echo generating files $nextname and $nextname2x and $nextname3x | |
cp $iconset/$base $iconset/$nextname | |
`sips -Z $nextsize $iconset/$nextname &>/dev/null` | |
cp $iconset/$base $iconset/$nextname2x | |
`sips -Z $nextsize2x $iconset/$nextname2x &>/dev/null` | |
cp $iconset/$base $iconset/$nextname3x | |
`sips -Z $nextsize3x $iconset/$nextname3x &>/dev/null` | |
: $[ i++ ] | |
done | |
echo use 167@1x for 83.5@2x iPad Pro | |
rm $iconset/$base |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment