-
Notifications
You must be signed in to change notification settings - Fork 0
/
scale-app-icons
executable file
·44 lines (37 loc) · 1.27 KB
/
scale-app-icons
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/zsh
function usage() {
NAME=$(basename "$0")
echo "Usage: ${NAME} <source-icon> <output-directory>"
}
IN_FILE="$1"
OUT_DIR="$2"
if [[ ! -r "$IN_FILE" ]]; then
echo "Missing source icon, or file not found: $IN_FILE"
usage
exit 1
fi
if [[ ! -d "$OUT_DIR" ]]; then
echo "Missing output directory, or directory not found: $OUT_DIR"
usage
exit 2
fi
FILENAME=$(basename "$IN_FILE")
echo "* Generating App Store marketing icon at 1024x1024 px"
APPSTORE_FILE="${OUT_DIR}/${FILENAME%.png}_marketing_1024.png"
echo "> convert '${IN_FILE}' -scale 1024x1024 '${APPSTORE_FILE}'"
gm convert "$IN_FILE" -scale 1024x1024 "$APPSTORE_FILE"
for SIZE in 20 29 38 40 60 64 68 76 83.5; do
PREFIX="${FILENAME%.png}_iOS_$SIZE"
echo "* Generating iOS icons at $SIZE points with filename prefix $PREFIX"
S=$((2 * SIZE))
gm convert "$IN_FILE" -scale ${S}x${S} "$OUT_DIR/[email protected]"
S=$((3 * SIZE))
gm convert "$IN_FILE" -scale ${S}x${S} "$OUT_DIR/[email protected]"
done
for SIZE in 16 32 128 256 512; do
PREFIX="${FILENAME%.png}_Mac_$SIZE"
echo "* Generating Mac icons at $SIZE points with filename prefix $PREFIX"
gm convert "$IN_FILE" -scale ${SIZE}x${SIZE} "$OUT_DIR/$PREFIX.png"
S=$((2 * SIZE))
gm convert "$IN_FILE" -scale ${S}x${S} "$OUT_DIR/[email protected]"
done