-
-
Save Lerg/b0a643a13f751747976f to your computer and use it in GitHub Desktop.
#!/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 "[email protected]" | |
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 "[email protected]" | |
convert "$base" -resize '100x100' -unsharp 1x4 "[email protected]" | |
convert "$base" -resize '114x114' -unsharp 1x4 "[email protected]" | |
convert "$base" -resize '120x120' -unsharp 1x4 "[email protected]" | |
convert "$base" -resize '144x144' -unsharp 1x4 "[email protected]" | |
convert "$base" -resize '152x152' -unsharp 1x4 "[email protected]" | |
convert "$base" -resize '180x180' -unsharp 1x4 "[email protected]" | |
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" |
unsharp is not blurring, it's sharpening.
It sharpens the image after resizing it.
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! "[email protected]"
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! "[email protected]"
convert "$base" -resize 100x100! "[email protected]"
convert "$base" -resize 114x114! "[email protected]"
convert "$base" -resize 120x120! "[email protected]"
convert "$base" -resize 144x144! "[email protected]"
convert "$base" -resize 152x152! "[email protected]"
convert "$base" -resize 180x180! "[email protected]"
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
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! "[email protected]"
convert "$base" -resize 87x87! "[email protected]"
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! "[email protected]"
convert "$base" -resize 100x100! "[email protected]"
convert "$base" -resize 114x114! "[email protected]"
convert "$base" -resize 120x120! "[email protected]"
convert "$base" -resize 144x144! "[email protected]"
convert "$base" -resize 152x152! "[email protected]"
convert "$base" -resize 83.5x83.5! "[email protected]"
convert "$base" -resize 180x180! "[email protected]"
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
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! "[email protected]"
convert "$base" -resize 134x100! "[email protected]"
convert "$base" -resize 120x90! "[email protected]"
convert "$base" -resize 180x135! "[email protected]"
convert "$base" -resize 54x40! "[email protected]"
convert "$base" -resize 81x60! "[email protected]"
convert "$base" -resize 64x48! "[email protected]"
convert "$base" -resize 96x72! "[email protected]"
convert "$base" -resize 1024x768! "Messages-AppStore.png"
fi
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.
#!/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
Added some new sizes, to be used with Zabbix Monitor.
#!/usr/bin/env bash
#
__imgSource=${1:-icon.png}
__imgDest=${__imgSource%.*}
__imgRepository=${2:-Icons}
#
[ -f ${__imgSource} ] || exit 0
[ -d ${__imgRepository} ] || mkdir -p ${__imgRepository}
#
__imgSize=(
"24x1" "48x1" "64x1" "96x1" "128x1"
"20x1" "20x2" "20x3"
"29x1" "29x2" "29x3"
"40x1" "40x2" "40x3"
"60x2" "60x3"
"76x1" "76x2"
"83.5x2" "1024x1"
)
#
for eSize in ${__imgSize[*]}; do
size=${eSize%x*}
scale=${eSize##*x}
resize=$(bc <<< ${size}*${scale} )
echo "resizing ${__imgSource} to ${size}x${size}@${scale}"
convert ${__imgSource} \
-resize ${resize}x${resize} \
-unsharp '1.5x1+0.7+0.02' \
${__imgRepository}/Icon-${__imgDest}-${size}x${size}@${scale}x.png
done
FWIW, I made a fork with the apple watch icon sizes here: https://gist.github.com/mgrider/3c25a49accf46f8953e7d4dc49fca2c1
You need imagemagick installed.
Put this file into /usr/bin,
Give execution mod: chmod +x
Usage:
Type in the terminal inside your app directory
icon1024.png - source image file, 1024x1024 or bigger