Created
October 18, 2018 21:46
-
-
Save shanev/6d030c10030c181b45602afb55ffb802 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# exit if there are any errors | |
set -e | |
# pretty output | |
info() { | |
local green="\033[1;32m" | |
local normal="\033[0m" | |
echo "[${green}INFO${normal}] $1" | |
} | |
# pretty errors | |
error() { | |
local red="\033[1;31m" | |
local normal="\033[0m" | |
echo "[${red}ERROR${normal}] $1" | |
} | |
# check ImageMagick | |
command -v convert >/dev/null 2>&1 || { error >&2 "The ImageMagick is not installed. Please use brew to install it first."; exit -1; } | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
BASE="$DIR/../iTunes/[email protected]" | |
OUTPUT="$DIR/../Blink/Assets.xcassets/AppIcon.appiconset/" | |
# ensure that the path points to a valid file. | |
if [ ! -f "$BASE" ] | |
then | |
echo "Invalid path to base file." | |
exit 1 | |
fi | |
# takes in the dimension of the icon (it assumes the icon is a square) and the name of the file to save the icon to. | |
createIconImage() | |
{ | |
iconDimension=$1 | |
iconName=$2 | |
convert "$BASE" -resize ${iconDimension}x${iconDimension}^ -gravity center -extent ${iconDimension}x${iconDimension} $OUTPUT/$iconName | |
} | |
info 'Generating app icons ...' | |
info '20pt iPhone Notification 2x' | |
createIconImage 40 icon-40.png | |
info '20pt iPhone Notification 3x' | |
createIconImage 60 icon-60.png | |
info '29pt Settings/Spotlight 2x' | |
createIconImage 58 icon-58.png | |
info '29pt Settings/Spotlight 3x' | |
createIconImage 87 icon-87.png | |
info '40pt Spotlight 2x' | |
createIconImage 80 icon-80.png | |
info '40pt Spotlight 3x' | |
createIconImage 120 icon-121.png | |
info '60pt iPhone app 2x' | |
createIconImage 120 icon-120.png | |
info '60pt iPhone app 3x' | |
createIconImage 180 icon-180.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment