1#!/bin/sh
2#
3# Copyright (c) 2015-2016 Marcus Rohrmoser http://mro.name/~me. All rights reserved.
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http: //www.gnu.org/licenses></http:>.
17#
18cd "$(dirname "$0")" ; mkdir build ; cd build
19
20src="../../Spray-2.svg"
21
22inkscape=/Applications/Inkscape.app/Contents/Resources/bin/inkscape
23
24${inkscape} --help >/dev/null 2>&1 || { echo "Inkscape is not installed." && exit 1; }
25pngquant --help >/dev/null 2>&1 || { echo "pngquant is not installed." && exit 1; }
26optipng -help >/dev/null 2>&1 || { echo "optipng is not installed." && exit 1; }
27
28pngquant="pngquant --skip-if-larger --speed 1"
29
30OPTS="--export-area-page --export-width=1024 --export-height=1024 --export-background=white --without-gui"
31
32
33dst="iTunesArtwork.png"
34"${inkscape}" --export-png="$(pwd)/${dst}" $OPTS --file="$(pwd)/${src}"
35${pngquant} "$(pwd)/${dst}" &
36
37dst=iTunesArtwork.svg
38cp "${src}" "${dst}"
39# http://stackoverflow.com/a/10492912
40${inkscape} "$(pwd)/${dst}" \
41 --verb=FileVacuum --verb=FileSave \
42 --verb=FileClose --verb=FileQuit
43${inkscape} $OPTS --vacuum-defs --export-plain-svg="$(pwd)/${dst}" --file="$(pwd)/${dst}"
44
45for siz in 29 40 60 76
46do
47 for scale in 1 2 3
48 do
49 dst="AppIcon-${siz}x${siz}@${scale}.png"
50 sips --resampleHeightWidthMax "$(($siz * $scale))" iTunesArtwork.png --out "${dst}"
51 ${pngquant} ${dst} &
52 done
53done
54
55siz=167
56scale=2
57dst="AppIcon-83x83@${scale}.png"
58sips --resampleHeightWidthMax "${siz}" iTunesArtwork.png --out "${dst}"
59${pngquant} ${dst} &
60
61wait
62
63for i in *-fs8.png
64do
65 mv "${i}" "$(basename "${i}" -fs8.png).png"
66done
67
68for i in *.png
69do
70 optipng -o 7 "$i" &
71done
72
73wait