Instantly share code, notes, and snippets.

Embed
What would you like to do?
Make all app icons with imagemagick, iOS and Android
#!/bin/sh
base=$1
convert "$base" -resize '29x29' -unsharp 1x4 "Icon-Small.png"
convert "$base" -resize '40x40' -unsharp 1x4 "Icon-Small-40.png"
convert "$base" -resize '50x50' -unsharp 1x4 "Icon-Small-50.png"
convert "$base" -resize '57x57' -unsharp 1x4 "Icon.png"
convert "$base" -resize '58x58' -unsharp 1x4 "Icon-Small@2x.png"
convert "$base" -resize '60x60' -unsharp 1x4 "Icon-60.png"
convert "$base" -resize '72x72' -unsharp 1x4 "Icon-72.png"
convert "$base" -resize '76x76' -unsharp 1x4 "Icon-76.png"
convert "$base" -resize '80x80' -unsharp 1x4 "Icon-Small-40@2x.png"
convert "$base" -resize '100x100' -unsharp 1x4 "Icon-Small-50@2x.png"
convert "$base" -resize '114x114' -unsharp 1x4 "Icon@2x.png"
convert "$base" -resize '120x120' -unsharp 1x4 "Icon-60@2x.png"
convert "$base" -resize '144x144' -unsharp 1x4 "Icon-72@2x.png"
convert "$base" -resize '152x152' -unsharp 1x4 "Icon-76@2x.png"
convert "$base" -resize '180x180' -unsharp 1x4 "Icon-60@3x.png"
convert "$base" -resize '512x512' -unsharp 1x4 "iTunesArtwork"
convert "$base" -resize '1024x1024' -unsharp 1x4 "iTunesArtwork@2x"
convert "$base" -resize '36x36' -unsharp 1x4 "Icon-ldpi.png"
convert "$base" -resize '48x48' -unsharp 1x4 "Icon-mdpi.png"
convert "$base" -resize '72x72' -unsharp 1x4 "Icon-hdpi.png"
convert "$base" -resize '96x96' -unsharp 1x4 "Icon-xhdpi.png"
convert "$base" -resize '144x144' -unsharp 1x4 "Icon-xxhdpi.png"
convert "$base" -resize '192x192' -unsharp 1x4 "Icon-xxxhdpi.png"
@Lerg

This comment has been minimized.

Owner

Lerg commented Jun 21, 2014

You need imagemagick installed.
Put this file into /usr/bin,
Give execution mod: chmod +x

Usage:
Type in the terminal inside your app directory

prepare_icons.sh icon1024.png

icon1024.png - source image file, 1024x1024 or bigger

@Lerg

This comment has been minimized.

Owner

Lerg commented Jun 21, 2014

unsharp is not blurring, it's sharpening.
It sharpens the image after resizing it.

@dergab

This comment has been minimized.

dergab commented Jun 1, 2015

Nice, thank you, @Lerg!

I've extended the script to do a simple input argument check and force resolutions (with !). The reason is that I made a script for launch images as well and here the aspect ratio was kept by imagemagick, resulting in some resolutions not being exactly as desired.

#!/bin/sh
base=$1

if [ -z $base ]
  then
    echo No argument given
else
  ##
  ## iOS files
  convert "$base" -resize 29x29!     "Icon-Small.png"
  convert "$base" -resize 40x40!     "Icon-Small-40.png"
  convert "$base" -resize 50x50!     "Icon-Small-50.png"
  convert "$base" -resize 57x57!     "Icon.png"
  convert "$base" -resize 58x58!     "Icon-Small@2x.png"
  convert "$base" -resize 60x60!     "Icon-60.png"
  convert "$base" -resize 72x72!     "Icon-72.png"
  convert "$base" -resize 76x76!     "Icon-76.png"
  convert "$base" -resize 80x80!     "Icon-Small-40@2x.png"
  convert "$base" -resize 100x100!   "Icon-Small-50@2x.png"
  convert "$base" -resize 114x114!   "Icon@2x.png"
  convert "$base" -resize 120x120!   "Icon-60@2x.png"
  convert "$base" -resize 144x144!   "Icon-72@2x.png"
  convert "$base" -resize 152x152!   "Icon-76@2x.png"
  convert "$base" -resize 180x180!   "Icon-60@3x.png"
  convert "$base" -resize 512x512!   "iTunesArtwork"
  convert "$base" -resize 1024x1024! "iTunesArtwork@2x"
  ##
  ## Android files
  convert "$base" -resize 36x36!    "Icon-ldpi.png"
  convert "$base" -resize 48x48!    "Icon-mdpi.png"
  convert "$base" -resize 72x72!    "Icon-hdpi.png"
  convert "$base" -resize 96x96!    "Icon-xhdpi.png"
  convert "$base" -resize 144x144!  "Icon-xxhdpi.png"
  convert "$base" -resize 192x192!  "Icon-xxxhdpi.png"
fi
@gduplessy

This comment has been minimized.

gduplessy commented Aug 25, 2016

Added a couple of new sizes in there (83.5 and icon-small@3x)

#!/bin/sh
base=$1

if [ -z $base ]
  then
    echo No argument given
else
  ##
  ## iOS files
  convert "$base" -resize 29x29!     "Icon-Small.png"
  convert "$base" -resize 40x40!     "Icon-Small-40.png"
  convert "$base" -resize 50x50!     "Icon-Small-50.png"
  convert "$base" -resize 57x57!     "Icon.png"
  convert "$base" -resize 58x58!     "Icon-Small@2x.png"
  convert "$base" -resize 87x87!     "Icon-Small@3x.png"
  convert "$base" -resize 60x60!     "Icon-60.png"
  convert "$base" -resize 72x72!     "Icon-72.png"
  convert "$base" -resize 76x76!     "Icon-76.png"
  convert "$base" -resize 80x80!     "Icon-Small-40@2x.png"
  convert "$base" -resize 100x100!   "Icon-Small-50@2x.png"
  convert "$base" -resize 114x114!   "Icon@2x.png"
  convert "$base" -resize 120x120!   "Icon-60@2x.png"
  convert "$base" -resize 144x144!   "Icon-72@2x.png"
  convert "$base" -resize 152x152!   "Icon-76@2x.png"
  convert "$base" -resize 83.5x83.5! "Icon-83.5@2x.png"
  convert "$base" -resize 180x180!   "Icon-60@3x.png"
  convert "$base" -resize 512x512!   "iTunesArtwork"
  convert "$base" -resize 1024x1024! "iTunesArtwork@2x"
  ##
  ## Android files
  convert "$base" -resize 36x36!    "Icon-ldpi.png"
  convert "$base" -resize 48x48!    "Icon-mdpi.png"
  convert "$base" -resize 72x72!    "Icon-hdpi.png"
  convert "$base" -resize 96x96!    "Icon-xhdpi.png"
  convert "$base" -resize 144x144!  "Icon-xxhdpi.png"
  convert "$base" -resize 192x192!  "Icon-xxxhdpi.png"
fi
@jamessa

This comment has been minimized.

jamessa commented Sep 12, 2016

For iOS 10 message extension icons.

#!/bin/sh
base=$1

if [ -z $base ]
  then
    echo No argument given
else
  ##
  ## iOS files
  convert "$base" -resize 148x110!   "Messages-74@2x.png"
  convert "$base" -resize 134x100!   "Messages-67@2x.png"
  convert "$base" -resize 120x90!    "Messages-60@2x.png"
  convert "$base" -resize 180x135!   "Messages-60@3x.png"
  convert "$base" -resize 54x40!     "Messages-27@2x.png"
  convert "$base" -resize 81x60!     "Messages-27@3x.png"
  convert "$base" -resize 64x48!     "Messages-32@2x.png"
  convert "$base" -resize 96x72!     "Messages-32@3x.png"
  convert "$base" -resize 1024x768!  "Messages-AppStore.png"
fi
@mxcl

This comment has been minimized.

mxcl commented Mar 27, 2017

For other people coming here, some of the above follow-up scripts input the POINTS values for sizes rather than PIXEL and thus need to be doubled.

@wenerme

This comment has been minimized.

wenerme commented Mar 26, 2018

#!/bin/sh

sizes="20x1 20x2 20x3 29x1 29x2 29x3 40x1 40x2 40x3 60x2 60x3 76x1 76x2 83.5x2 1024x1"
source=${1:-logo.svg}
dst=${2:-.}
for s in $sizes;do
  size=${s%x*}
  scale=${s##*x}
  resize=$(bc <<< ${size}*${scale} )
  convert "$source" -resize ${resize}x${resize}     -unsharp 1x4 $dst/"Icon-App-${size}x${size}@${scale}x.png"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment