Skip to content

Instantly share code, notes, and snippets.

@yene
Created October 9, 2019 18:25
Show Gist options
  • Save yene/f1ad6bbf843c595b744025f8e865f613 to your computer and use it in GitHub Desktop.
Save yene/f1ad6bbf843c595b744025f8e865f613 to your computer and use it in GitHub Desktop.
Generating icons for Xcode
#!/bin/bash
# pass in the file name of the source as first parameter
mkdir -p generated
rm generated/*
# remove alpha with a simple trick
sips -s format bmp "$1" --out tmp.bmp
sips -s format png tmp.bmp --out "$1"
rm tmp.bmp
# cutting AppIcon for iPhone
sips -Z 40 --out generated/[email protected] "$1"
sips -Z 60 --out generated/[email protected] "$1"
sips -Z 29 --out generated/[email protected] "$1"
sips -Z 58 --out generated/[email protected] "$1"
sips -Z 87 --out generated/[email protected] "$1"
sips -Z 80 --out generated/[email protected] "$1"
sips -Z 120 --out generated/[email protected] "$1"
sips -Z 57 --out generated/[email protected] "$1"
sips -Z 114 --out generated/[email protected] "$1"
sips -Z 120 --out generated/[email protected] "$1" # quality check this, iPhone < 6 icon
sips -Z 180 --out generated/[email protected] "$1" # quality check this, iPhone > 6 icon
# cutting AppIcon for iPad
sips -Z 20 --out generated/icon-20@1x~ipad.png "$1"
sips -Z 40 --out generated/icon-20@2x~ipad.png "$1"
sips -Z 29 --out generated/icon-29@1x~ipad.png "$1"
sips -Z 58 --out generated/icon-29@2x~ipad.png "$1"
sips -Z 40 --out generated/icon-40@1x~ipad.png "$1"
sips -Z 80 --out generated/icon-40@2x~ipad.png "$1"
sips -Z 76 --out generated/icon-76@1x~ipad.png "$1"
sips -Z 152 --out generated/icon-76@2x~ipad.png "$1" # quality check this, iPad icon
sips -Z 167 --out generated/icon-83.5@2x~ipad.png "$1" # quality check this, iPad Pro icon
# store
sips -Z 1024 --out generated/icon-1024@1x~ios-marketing.png "$1" # quality check this, it is shown in the App Store
# mac icons
#sips -Z 16 --out generated/icon-16@1x~mac.png "$1"
#sips -Z 32 --out generated/icon-16@2x~mac.png "$1"
#sips -Z 32 --out generated/icon-32@1x~mac.png "$1"
#sips -Z 64 --out generated/icon-32@2x~mac.png "$1"
#sips -Z 128 --out generated/icon-128@1x~mac.png "$1"
#sips -Z 256 --out generated/icon-128@2x~mac.png "$1"
#sips -Z 256 --out generated/icon-256@1x~mac.png "$1"
#sips -Z 512 --out generated/icon-256@2x~mac.png "$1"
#sips -Z 512 --out generated/icon-512@1x~mac.png "$1"
#sips -Z 1024 --out generated/icon-512@2x~mac.png "$1"
# cutting AppIcon for watchOS
#sips -Z 48 --out generated/w-icon-24@2x~watch.png "$1"
#sips -Z 55 --out generated/w-icon-27.5@2x~watch.png "$1"
#sips -Z 58 --out generated/w-icon-29@2x~watch.png "$1"
#sips -Z 87 --out generated/w-icon-29@3x~watch.png "$1"
#sips -Z 80 --out generated/w-icon-40@2x~watch.png "$1"
#sips -Z 88 --out generated/w-icon-44@2x~watch.png "$1"
#sips -Z 100 --out generated/w-icon-50@2x~watch.png "$1"
#sips -Z 172 --out generated/w-icon-86@2x~watch.png "$1"
#sips -Z 196 --out generated/w-icon-98@2x~watch.png "$1"
#sips -Z 216 --out generated/w-icon-108@2x~watch.png "$1"
#sips -Z 1024 --out generated/w-icon-1024@1x~watch-marketing.png "$1"
echo "cut all the images and placed them into the folder ./generated"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment