Skip to content

Instantly share code, notes, and snippets.

@wilsolutions
Created August 14, 2018 13:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wilsolutions/e65e22312b3bba567e7612a87c765d51 to your computer and use it in GitHub Desktop.
#!/bin/sh
: '
Requirements:
$ brew install imagemagick
Usage:
$ ./icon-tool iconPath destination
Where:
* iconpath: the path of the icon you will use as source, it has be 1024 x 1024. Defaults to: ../skin/res/ios/icon.png
* destination: the folder where you want to output the icon. Defaults to: ../skin/res/ios/icons
- Android ouput:
Not available yet, it will be generated by Android studio for now.
- iOS output:
<icon src="res/ios/icons/Icon-App-20x20@1x.png" width="20" height="20" />
<icon src="res/ios/icons/Icon-App-20x20@2x.png" width="40" height="40" />
<icon src="res/ios/icons/Icon-App-20x20@3x.png" width="60" height="60" />
<icon src="res/ios/icons/Icon-App-29x29@1x.png" width="29" height="29" />
<icon src="res/ios/icons/Icon-App-29x29@2x.png" width="58" height="58" />
<icon src="res/ios/icons/Icon-App-29x29@3x.png" width="87" height="87" />
<icon src="res/ios/icons/Icon-App-40x40@1x.png" width="40" height="40" />
<icon src="res/ios/icons/Icon-App-40x40@2x.png" width="80" height="80" />
<icon src="res/ios/icons/Icon-App-40x40@3x.png" width="120" height="120" />
<icon src="res/ios/icons/Icon-App-57x57@1x.png" width="57" height="57" />
<icon src="res/ios/icons/Icon-App-57x57@2x.png" width="114" height="114" />
<icon src="res/ios/icons/Icon-App-60x60@1x.png" width="60" height="60" />
<icon src="res/ios/icons/Icon-App-60x60@2x.png" width="120" height="120" />
<icon src="res/ios/icons/Icon-App-60x60@3x.png" width="180" height="180" />
<icon src="res/ios/icons/Icon-App-72x72@1x.png" width="72" height="72" />
<icon src="res/ios/icons/Icon-App-72x72@2x.png" width="144" height="144" />
<icon src="res/ios/icons/Icon-App-76x76@1x.png" width="76" height="76" />
<icon src="res/ios/icons/Icon-App-76x76@2x.png" width="152" height="152" />
<icon src="res/ios/icons/Icon-App-76x76@3x.png" width="228" height="228" />
<icon src="res/ios/icons/Icon-App-83.5x83.5@2x.png" width="167" height="167" />
<icon src="res/ios/icons/Icon-App-50x50@1x.png" width="50" height="50" />
<icon src="res/ios/icons/Icon-App-50x50@2x.png" width="100" height="100" />
<icon src="res/ios/icons/Icon-App-24x24@2x.png" width="48" height="48" />
<icon src="res/ios/icons/Icon-App-27.5x27.5@2x.png" width="55" height="55" />
<icon src="res/ios/icons/Icon-App-44x44@2x.png" width="88" height="88" />
<icon src="res/ios/icons/Icon-App-86x86@2x.png" width="172" height="172" />
<icon src="res/ios/icons/Icon-App-98x98@2x.png" width="196" height="196" />
<icon src="res/ios/icons/Icon-App-1024x1024@1x.png" width="1024" height="1024" />
'
sizes="20x1 20x2 20x3 24x2 27.5x2 29x1 29x2 29x3 40x1 40x2 40x3 44x2 50x1 50x2 57x1 57x2 60x1 60x2 60x3 72x1 72x2 76x1 76x2 76x3 83.5x2 86x2 98x2 1024x1"
source=${1:-"../skin/res/ios/icon.png"}
dst=${2:-"../skin/res/ios/icons"}
for s in $sizes;do
size=${s%x*}
scale=${s##*x}
resize=$(bc <<< ${size}*${scale} )
generatedIcon=$dst/"Icon-App-${size}x${size}@${scale}x.png"
convert "$source" -resize ${resize}x${resize} $generatedIcon
if [ -f $generatedIcon ];
then
echo "Created: $generatedIcon"
else
echo "Could not create $generatedIcon"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment