Skip to content

Instantly share code, notes, and snippets.

@marcuswestin
Created October 9, 2013 20:09
Show Gist options
  • Save marcuswestin/6907510 to your computer and use it in GitHub Desktop.
Save marcuswestin/6907510 to your computer and use it in GitHub Desktop.
Generate all xcode 5 app icon sizes from one original large icon
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
@paulschmidt
Copy link

Pretty slick- I mentioned this in my blog post: http://www.paulrschmidt.net/archives/92

@thorp
Copy link

thorp commented Oct 22, 2015

Thanks for the great script, it saved a lot of time!
Here's an updated the version for the latest Xcode icon sizes:

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 87 --out generated/iPhoneSettings-29x29@3x.png sourceIcon.png
sips -Z 80 --out generated/iPhoneSpotlight-40x40@2x.png sourceIcon.png
sips -Z 120 --out generated/iPhoneSpotlight-40x40@3x.png sourceIcon.png
sips -Z 120 --out generated/iPhoneApp-60x60@2x.png sourceIcon.png
sips -Z 180 --out generated/iPhoneApp-60x60@3x.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

@stgarf
Copy link

stgarf commented Nov 14, 2017

Updated for Xcode 9 and iOS 11.

mkdir -p generated

# iPhone Notification (iOS 7-11) 20pt
sips -Z 40 --out generated/iPhoneNotification-20x20@2x.png sourceIcon.png
sips -Z 60 --out generated/iPhoneNotification-20x20@3x.png sourceIcon.png

# iPhone Spotlight (iOS 7-11) 40pt
sips -Z 80  --out generated/iPhoneSpotlight-40x40@2x.png sourceIcon.png
sips -Z 120 --out generated/iPhoneSpotlight-40x40@3x.png sourceIcon.png

# iPhone App (iOS 7-11) 60pt
sips -Z 120 --out generated/iPhoneApp-60x60@2x.png sourceIcon.png
sips -Z 180 --out generated/iPhoneApp-60x60@3x.png sourceIcon.png

# ---------------------------------------------------------------------------
# iPhone Spotlight/Settings (iOS 5,6/iOS 5-11) 29pt
sips -Z 58 --out generated/iPhoneSpotlightSettings-29x29@2x.png sourceIcon.png
sips -Z 87 --out generated/iPhoneSpotlightSettings-29x29@3x.png sourceIcon.png

# ---------------------------------------------------------------------------
# iPad Notification (iOS 7-11) 20pt
sips -Z 20 --out generated/iPadNotifications-20x20.png sourceIcon.png
sips -Z 40 --out generated/iPadNotifications-20x20@2x.png sourceIcon.png

# iPad Settings (iOS 5-11) 29pt
sips -Z 29 --out generated/iPadSettings-29x29.png sourceIcon.png
sips -Z 58 --out generated/iPadSettings-29x29@2x.png sourceIcon.png

# iPad Spotlight (iOS 7-11) 40pt
sips -Z 40 --out generated/iPadSpotlight-20x20.png sourceIcon.png
sips -Z 80 --out generated/iPadSpotlight-20x20@2x.png sourceIcon.png

# iPad App (iOS 7-11) 76pt
sips -Z 76 --out generated/iPadApp-76x76.png sourceIcon.png
sips -Z 152 --out generated/iPadApp-76x76@2x.png sourceIcon.png

# ---------------------------------------------------------------------------
# iPad Pro App (iOS 9-11) 83.5pt
sips -Z 167 --out generated/iPadProApp-83.5x83.5@2x.png sourceIcon.png

# ---------------------------------------------------------------------------
# App Store (iOS) 1024pt
sips -Z 1024 --out generated/AppStore-1024x1024.png sourceIcon.png

@daneov
Copy link

daneov commented Dec 11, 2017

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