Created
February 11, 2014 09:04
-
-
Save dhogborg/8931506 to your computer and use it in GitHub Desktop.
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/zsh | |
ai_help() | |
{ | |
echo "appicons [platform] [input-file] [output-dir]" | |
echo "" | |
echo "Default output directory is Icons/ or res/ depending on platform" | |
echo "For android output, specify path to res/ folder." | |
echo "" | |
echo "[platform] can be either 'ios' or 'android'" | |
} | |
ai_generate_ios() | |
{ | |
input=$1; | |
output=$2; | |
if [ "$output" = "" ]; then | |
output="Icons" | |
fi | |
mkdir -p "$output"; | |
# iPad, iPhone settings | |
ai_generate_size "$input" "$output/Icon-29.png" 29; | |
ai_generate_size "$input" "$output/Icon-29@2x.png" 58; | |
# iPhone, iPad spotlight iOS7 | |
ai_generate_size "$input" "$output/Icon-40.png" 40; | |
ai_generate_size "$input" "$output/Icon-40@2x.png" 80; | |
# iPhone icon iOS6 | |
ai_generate_size "$input" "$output/Icon-57.png" 57; | |
ai_generate_size "$input" "$output/Icon-57@2x.png" 114; | |
# iPhone icon iOS7 | |
ai_generate_size "$input" "$output/Icon-60@2x.png" 120; | |
# ipad spotlight iOS6 | |
ai_generate_size "$input" "$output/Icon-50.png" 50; | |
ai_generate_size "$input" "$output/Icon-50@2x.png" 100; | |
#iPad icon iOS 7 | |
ai_generate_size "$input" "$output/Icon-72.png" 72; | |
ai_generate_size "$input" "$output/Icon-72@2x.png" 144; | |
# iPad icon iOS7 | |
ai_generate_size "$input" "$output/Icon-76.png" 76; | |
ai_generate_size "$input" "$output/Icon-76@2x.png" 152; | |
# spotlight and settings icons | |
ai_generate_size "$input" "$output/Icon-512.png" 512; | |
ai_generate_size "$input" "$output/Icon-1024.png" 1024; | |
} | |
ai_generate_android() | |
{ | |
input=$1; | |
output=$2; | |
if [ "$output" = "" ]; then | |
output="res" | |
fi | |
mkdir -p "$output"; | |
mkdir -p "$output/drawable-ldpi" "$output/drawable-mdpi" "$output/drawable-hdpi" "$output/drawable-xhdpi" "$output/drawable-xxhdpi"; | |
ai_generate_size "$input" "$output/drawable-ldpi/ic_launcher.png" 36; | |
ai_generate_size "$input" "$output/drawable-mdpi/ic_launcher.png" 48; | |
ai_generate_size "$input" "$output/drawable-hdpi/ic_launcher.png" 72; | |
ai_generate_size "$input" "$output/drawable-xhdpi/ic_launcher.png" 96; | |
ai_generate_size "$input" "$output/drawable-xxhdpi/ic_launcher.png" 144; | |
} | |
# params: from to size | |
ai_generate_size() | |
{ | |
convert "$1" -resize "${3}x${3}" "$2"; | |
} | |
if [ "$1" = "" ]; then | |
echo "Need at least platform and input file"; | |
echo ""; | |
ai_help; | |
exit -1; | |
fi | |
if [ ! -f $2 ]; then | |
echo "Input file '$2' does not exists"; | |
exit -1; | |
fi | |
platform=$1; | |
case $platform in | |
"ios") ai_generate_ios $2 $3;; | |
"android") ai_generate_android $2 $3;; | |
*) ai_help;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment