Created
October 9, 2013 20:09
-
-
Save marcuswestin/6907510 to your computer and use it in GitHub Desktop.
Generate all xcode 5 app icon sizes from one original large icon
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
mkdir -p generated | |
sips -Z 29 --out generated/iPhoneSettings-29x29.png sourceIcon.png | |
sips -Z 58 --out generated/iPhoneSettings-29x29@2x.png sourceIcon.png | |
sips -Z 80 --out generated/iPhoneSpotlight-40x40@2x.png sourceIcon.png | |
sips -Z 120 --out generated/iPhoneApp-60x60@2x.png sourceIcon.png | |
sips -Z 29 --out generated/iPadSettings-29x29.png sourceIcon.png | |
sips -Z 58 --out generated/iPadSettings-29x29@2x.png sourceIcon.png | |
sips -Z 40 --out generated/iPadSpotlight-40x40.png sourceIcon.png | |
sips -Z 80 --out generated/iPadSpotlight-40x40@2x.png sourceIcon.png | |
sips -Z 76 --out generated/iPadApp-76x76.png sourceIcon.png | |
sips -Z 152 --out generated/iPadApp-76x76@2x.png sourceIcon.png | |
#cp generated/*.png path/to/Images.xcassets/AppIcon.appiconset |
For those running Bash v4 (brew install), this is a bit more future-proof and based on Apple Docs:
#!/bin/bash
OUTPUT="generated"
mkdir -p ${OUTPUT}
APP_ICON=$1
declare -A iphone
declare -A appstore
declare -A watchos
iphone=(['Icon-60@2x']='120' ['Icon-60@3x']='180' ['Icon-76']='76' ['Icon-76@2x']='152' ['Icon-83.5@2x']='167' ['Icon-Small-40']='40' ['Icon-Small-40@2x']='80' ['Icon-Small-40@3x']='120' ['Icon-Small']='29' ['Icon-Small@2x']='58' ['Icon-Small@3x']='87')
watchos=(['AppIcon40x40@2x']='80' ['AppIcon44x44@2x']='88' ['AppIcon86x86@2x']='172' ['AppIcon98x98@2x']='196' ['AppIcon24x24@2x']='48' ['AppIcon27.5x27.5@2x']='55' ['AppIcon29x29@2x']='58' ['AppIcon29x29@3x']='87')
appstore=(['iTunesArtwork']='512' ['iTunesArtwork@2x']='1024')
function process_array
{
local -n array
array=$1
folder_name=$2
for image_name in "${!array[@]}";
do
value="${array[$image_name]}"
echo "Creating $image_name with resolution $value"
sips -Z $value --out "$folder_name/$image_name.png" "$APP_ICON"
done
}
script_name=`basename "$0"`
if [[ -z "$APP_ICON" ]]; then
echo "Usage: $script_name.sh <path_to_icon>"
exit 1
fi
mkdir -p "$OUTPUT/iphone"
mkdir -p "$OUTPUT/watchos"
mkdir -p "$OUTPUT/appstore"
process_array iphone "$OUTPUT/iphone"
process_array watchos "$OUTPUT/watchos"
process_array appstore "$OUTPUT/appstore"
Put it in e.g. script.sh
, and call the script with ./script.sh path_to_image
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated for Xcode 9 and iOS 11.