Skip to content

Instantly share code, notes, and snippets.

@TyrfingMjolnir
Last active February 26, 2019 06:23
Show Gist options
  • Save TyrfingMjolnir/b4944cfa74586a8b25884b52e8f38274 to your computer and use it in GitHub Desktop.
Save TyrfingMjolnir/b4944cfa74586a8b25884b52e8f38274 to your computer and use it in GitHub Desktop.
Convert 1 image 2048x2048 to all needed sizes for an iOS app

Based on

https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/image-size-and-resolution/

Prerequisite

$ brew install imagemagick

This is one way to run this script:

$ time /opt/local/convertappicons/convertappicons.sh AppName.png
AppName

real	0m4.272s
user	0m5.478s
sys	0m0.547s
$ exa -T AppName
AppName
├── Icon-60.png
├── [email protected]
├── [email protected]
├── Icon-72.png
├── [email protected]
├── Icon-76.png
├── [email protected]
├── [email protected]
├── [email protected]
├── Icon-Small-50.png
├── [email protected]
├── Icon-Small.png
├── [email protected]
├── [email protected]
├── Icon-Spotlight-40.png
├── [email protected]
├── [email protected]
├── Icon.png
├── [email protected]
├── iTunesArtwork
└── iTunesArtwork@2
$ open AppName

Then drag all the files from the newly opened folder on to your app icon grid.

#!/usr/bin/env bash
### Note that if your image is 2048 x 2048 as an example there is no need for -resize to have 2 parameters,
### however if your original image is 4097 x 4095, the 2 parameters will "correct" this.
### https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/image-size-and-resolution/
echo ${1%.*}
/bin/mkdir "${1%.*}"
/usr/local/bin/convert "$1" -resize '1024x1024' "${1%.*}/iTunesArtwork@2"
/usr/local/bin/convert "$1" -resize '1024x1024' "${1%.*}/Icon-AppStore-1024.png"
/usr/local/bin/convert "$1" -resize '512x512' "${1%.*}/iTunesArtwork"
/usr/local/bin/convert "$1" -resize '167x167' "${1%.*}/[email protected]"
/usr/local/bin/convert "$1" -resize '76x76' "${1%.*}/Icon-iPadApp-76.png"
/usr/local/bin/convert "$1" -resize '152x152' "${1%.*}/[email protected]"
/usr/local/bin/convert "$1" -resize '80x80' "${1%.*}/[email protected]"
/usr/local/bin/convert "$1" -resize '40x40' "${1%.*}/Icon-iPadSpotlight-40.png"
/usr/local/bin/convert "$1" -resize '58x58' "${1%.*}/[email protected]"
/usr/local/bin/convert "$1" -resize '29x29' "${1%.*}/Icon-iPadSettings-29.png"
/usr/local/bin/convert "$1" -resize '40x40' "${1%.*}/[email protected]"
/usr/local/bin/convert "$1" -resize '20x20' "${1%.*}/Icon-iPadNotifications-20.png"
/usr/local/bin/convert "$1" -resize '180x180' "${1%.*}/[email protected]"
/usr/local/bin/convert "$1" -resize '120x120' "${1%.*}/[email protected]"
/usr/local/bin/convert "$1" -resize '114x114' "${1%.*}/[email protected]"
/usr/local/bin/convert "$1" -resize '57x57' "${1%.*}/Icon-iPhoneApp-57.png"
/usr/local/bin/convert "$1" -resize '120x120' "${1%.*}/[email protected]"
/usr/local/bin/convert "$1" -resize '80x80' "${1%.*}/[email protected]"
/usr/local/bin/convert "$1" -resize '87x87' "${1%.*}/[email protected]"
/usr/local/bin/convert "$1" -resize '58x58' "${1%.*}/[email protected]"
/usr/local/bin/convert "$1" -resize '29x29' "${1%.*}/Icon-iPhoneSettings-29.png"
/usr/local/bin/convert "$1" -resize '60x60' "${1%.*}/[email protected]"
/usr/local/bin/convert "$1" -resize '40x40' "${1%.*}/[email protected]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment