Skip to content

Instantly share code, notes, and snippets.

@beny
Last active December 10, 2018 13:20
Show Gist options
  • Save beny/181d5ed78c3520037e355b31e11250d1 to your computer and use it in GitHub Desktop.
Save beny/181d5ed78c3520037e355b31e11250d1 to your computer and use it in GitHub Desktop.
Icon sizes generator for iOS/watchOS/iMessage apps.
#!/bin/bash
# Sizes from https://developer.apple.com/library/ios/#qa/qa1686/_index.html
# Requirements: ImageMagick
function resize {
GREEN='\033[0;32m'
BLUE='\033[0;34m'
DEFAULT='\033[0m'
echo -e "Generating ${BLUE}$3${DEFAULT} at size ${GREEN}$2 ${DEFAULT}"
convert $1 -resize $2 $3
}
if [ $1 = '-h' ]; then
echo "As first param use one of [iphone/ipad/ios/watchos/imessages]"
echo "keyword, the second param is path to the large image"
echo ""
echo "generator iphone 1024.png"
echo "generator ios 1024.png"
fi
# Icons for iPhone-only Applications
if [ $1 = 'iphone' ]; then
resize $2 512x512 iTunesArtwork.png # App list in iTunes
resize $2 1024x1024 iTunesArtwork@2x.png # App list in iTunes on devices with retina display
resize $2 120x120 Icon-60@2x.png # Home screen on iPhone/iPod Touch with retina display
resize $2 180x180 Icon-60@3x.png # Home screen on iPhone with retina HD display
resize $2 76x76 Icon-76.png # Home screen on iPad
resize $2 152x152 Icon-76@2x.png # Home screen on iPad with retina display
resize $2 167x167 Icon-83.5@2x.png # Home screen on iPad Pro
resize $2 40x40 Icon-Small-40.png # Spotlight
resize $2 80x80 Icon-Small-40@2x.png # Spotlight on devices with retina display
resize $2 120x120 Icon-Small-40@3x.png # Spotlight on devices with retina HD display
resize $2 29x29 Icon-Small.png # Settings
resize $2 58x58 Icon-Small@2x.png # Settings on devices with retina display
resize $2 87x87 Icon-Small@3x.png # Settings on devices with retina HD display
# Apple does not list these sizes
resize $2 40x40 Icon-Small-20@2x.png # iPhone notification iOS 7-11 on devices with retina display
resize $2 60x60 Icon-Small-20@3x.png # iPhone notification iOS 7-11 on devices with retina HD display
fi
# Icons for iPad-only Applications
if [ $1 = 'ipad' ]; then
resize $2 512x512 iTunesArtwork.png # Ad Hoc iTunes
resize $2 1024x1024 iTunesArtwork@2x.png # Ad Hoc iTunes on devices with retina display
resize $2 76x76 Icon-76.png # Home screen on iPad
resize $2 152x152 Icon-76@2x.png # Home screen on iPad with retina display
resize $2 167x167 Icon-83.5@2x.png # Home screen on iPad Pro
resize $2 40x40 Icon-Small-40.png # Spotlight
resize $2 80x80 Icon-Small-40@2x.png # Spotlight on devices with retina display
resize $2 29x29 Icon-Small.png # Settings
resize $2 58x58 Icon-Small@2x.png # Settings on devices with retina display
# Apple does not list these sizes
resize $2 20x20 Icon-Small-20.png # iPad notification iOS 7-11
resize $2 40x40 Icon-Small-20@2x.png # iPad notification iOS 7-11 on devices with retina display
fi
# Icons for Universal Applications
if [ $1 = 'ios' ]; then
resize $2 512x512 iTunesArtwork.png # App list in iTunes
resize $2 1024x1024 iTunesArtwork@2x.png # App list in iTunes for devices with retina display
resize $2 120x120 Icon-60@2x.png # Home screen on iPhone/iPod Touch with retina display
resize $2 180x180 Icon-60@3x.png # Home screen on iPhone with retina HD display
resize $2 76x76 Icon-76.png # Home screen on iPad
resize $2 152x152 Icon-76@2x.png # Home screen on iPad with retina display
resize $2 167x167 Icon-83.5@2x.png # Home screen on iPad Pro
resize $2 40x40 Icon-Small-40.png # Spotlight
resize $2 80x80 Icon-Small-40@2x.png # Spotlight on devices with retina display
resize $2 120x120 Icon-Small-40@3x.png # Spotlight on devices with retina HD display
resize $2 29x29 Icon-Small.png # Settings
resize $2 58x58 Icon-Small@2x.png # Settings on devices with retina display
resize $2 87x87 Icon-Small@3x.png # Settings on devices with retina HD display
# Apple does not list these sizes
resize $2 20x20 Icon-Small-20.png # iPad notification iOS 7-11
resize $2 40x40 Icon-Small-20@2x.png # iPhone/iPad notification iOS 7-11 on devices with retina display
resize $2 60x60 Icon-Small-20@3x.png # iPhone notification iOS 7-11 on devices with retina HD display
fi
# Icons for Watch Applications
if [ $1 = 'watchos' ]; then
resize $2 80x80 AppIcon40x40@2x.png # Home screen on Apple Watch (38mm/42mm), Long-Look notification on Apple Watch (38mm)
resize $2 88x88 AppIcon44x44@2x.png # Long-Look notification on Apple Watch (42mm)
resize $2 172x172 AppIcon86x86@2x.png # Short-Look notification on Apple Watch (38mm)
resize $2 196x196 AppIcon98x98@2x.png # Short-Look notification on Apple Watch (42mm)
resize $2 48x48 AppIcon24x24@2x.png # Notification center on Apple Watch (38mm)
resize $2 55x55 AppIcon27.5x27.5@2x.png # Notification center on Apple Watch (42mm)
resize $2 58x58 AppIcon29x29@2x.png # Settings in the Apple Watch companion app on iPhone
resize $2 87x87 AppIcon29x29@3x.png # Settings in the Apple Watch companion app on iPhone 6 Plus
fi
# Icons for iMessage Extensions
if [ $1 = 'imessage' ]; then
resize $2 1024x768 Messages1024x768.png # Messages App Store
resize $2 120x90 Messages60x45@2x.png # Messages app drawer on iPhone/iPod Touch with retina display
resize $2 180x135 Messages60x45@3x.png # Messages app drawer on iPhone with retina HD display
resize $2 134x100 Messages67x50@2x.png # Messages app drawer on iPad with retina display
resize $2 148x110 Messages74x55@2x.png # Messages app drawer on iPad Pro
resize $2 54x40 Messages27x20@2x.png # Breadcrumb icons in the chat transcript on devices with retina display.
resize $2 81x60 Messages27x20@3x.png # Breadcrumb icons in the chat transcript on iPhone with retina HD display
resize $2 64x48 Messages32x24@2x.png # Messages app management screen, message bubble branding on devices with retina display
resize $2 96x72 Messages32x24@3x.png # Messages app management screen, message bubble branding on iPhone with retina HD display
fi
@monkeywithacupcake
Copy link

There is a typo in help. As first param use one of [iphone/ipad/ios/watchos/imessages] should end with imessage as the code shows.

To use this awesome tool, copy the file to your computer. Open shell,

bash icons-generator.sh param1(type) param2(path/to/image.png)

@monkeywithacupcake
Copy link

monkeywithacupcake commented May 31, 2018

Update for iOS

if [ $1 = 'ios' ]; then
  #resize $2 512x512    iTunesArtwork.png     # App list in iTunes
  resize $2 1024x1024  iTunesArtwork@2x.png  # App list in iTunes for devices with retina display
  resize $2 120x120    Icon-60@2x.png        # Home screen on iPhone/iPod Touch with retina display
  resize $2 180x180    Icon-60@3x.png        # Home screen on iPhone with retina HD display
  resize $2 72x72      Icon-72.png           # Home screen on iPad iOS 5,6
  resize $2 144X144    Icon-72@2x.png        # Home screen on iPad with retina display iOS 5,6
  resize $2 76x76      Icon-76.png           # Home screen on iPad
  resize $2 152x152    Icon-76@2x.png        # Home screen on iPad with retina display
  resize $2 167x167    Icon-83.5@2x.png      # Home screen on iPad Pro
  resize $2 40x40      Icon-40.png           # Spotlight
  resize $2 80x80      Icon-40@2x.png        # Spotlight on devices with retina display
  resize $2 120x120    Icon-40@3x.png        # Spotlight on devices with retina HD display
  resize $2 29x29      Icon-29.png           # Settings
  resize $2 58x58      Icon-29@2x.png        # Settings on devices with retina display
  resize $2 87x87      Icon-29@3x.png        # Settings on devices with retina HD display
  resize $2 50X50      Icon-50.png           # iPad Spotlight iOS 5,6
  resize $2 100x100      Icon-50@2x.png        # iPad Spotlight iOS 5,6
  resize $2 57X57      Icon-57.png           # Home screen on iPhone iOS 5,6
  resize $2 114X114    Icon-57@2x.png        # Home screen on iPhone with retina display iOS 5,6

  # Apple does not list these sizes
  resize $2 20x20      Icon-Small-20.png     # iPad notification iOS 7-11
  resize $2 40x40      Icon-Small-20@2x.png  # iPhone/iPad notification iOS 7-11 on devices with retina display
  resize $2 60x60      Icon-Small-20@3x.png  # iPhone notification iOS 7-11 on devices with retina HD display

fi

@rfistman
Copy link

I don't have ImageMagick, so I replaced it with sips:

res=`echo $2 | cut -dx -f1`
#convert $1 -resize $2 $3
sips -Z $res --out "$3" "$1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment