Supporters update.
[dcpomatic.git] / graphics / update
1 #!/bin/bash -e
2 #
3 # Update generated stuff in graphics/ from the source files.
4 #
5 # It would be nice to do this with waf but:
6 # a) getting the wscript right is a complete pain in the arse
7 # b) running Inkscape from the command line on OS X is a complete pain in the arse
8
9 set -e
10
11 pwd=`pwd`
12 if [ `basename $pwd` != "graphics" ]; then
13     echo "$0: run within graphics/"
14     exit 1
15 fi
16
17 function required_font()
18 {
19     set +e
20     check=$(fc-list | grep "$1")
21     set -e
22     if [ "$check" == "" ]; then
23         echo "Missing font $1"
24         exit 1
25     fi
26 }
27
28 svg_apps="dcpomatic2_kdm dcpomatic2_server dcpomatic2_batch dcpomatic2_player dcpomatic2_playlist dcpomatic2_disk dcpomatic2_combiner dcpomatic2_editor"
29
30
31 if [ `uname -s` == "Darwin" ]; then
32     # Convert OS X icons using OS X-only iconutil
33     for p in dcpomatic2 $svg_apps; do
34         iconutil --convert icns --output osx/$p.icns osx/$p.iconset
35     done
36 else
37     required_font "Libre Baskerville"
38
39     INKSCAPE="$HOME/Applications/inkscape"
40     for c in icotool convert inkbatch $INKSCAPE; do
41         if [ ! -x "$(command -v $c)" ]; then
42             echo "$c is required"
43             exit 1
44         fi
45     done
46
47     INKSCAPE_EXPORT="$INKSCAPE -C --export-type=png"
48
49     # OS X application icons
50     mkdir -p osx
51     for r in 16 32 128 256 512; do
52         for p in dcpomatic2; do
53             mkdir -p osx/$p.iconset
54             convert src/dcpomatic.png -resize $rx$r osx/$p.iconset/icon_${r}x${r}.png
55             convert src/dcpomatic.png -resize $rx$r osx/$p.iconset/icon_${r}x${r}@2x.png
56         done
57         for p in $svg_apps; do
58             mkdir -p osx/$p.iconset
59             $INKSCAPE_EXPORT --export-filename=osx/$p.iconset/icon_${r}x${r}.png -w $r -h $r src/$p.svg
60             $INKSCAPE_EXPORT --export-filename=osx/$p.iconset/icon_${r}x${r}@2x.png -w $r -h $r src/$p.svg
61         done
62     done
63
64     # Linux application icons
65     mkdir -p linux
66     for r in 16 22 32 48 64 128 256 512; do
67         mkdir -p linux/$r
68         convert src/dcpomatic.png -resize $rx$r linux/$r/dcpomatic2.png
69         for p in $svg_apps; do
70             $INKSCAPE_EXPORT --export-filename=linux/$r/$p.png src/$p.svg -w $r -h $r
71         done
72     done
73
74     # Windows application icons
75     mkdir -p windows
76     for p in dcpomatic2 $svg_apps; do
77         icotool -c -o windows/$p.ico linux/16/$p.png linux/32/$p.png linux/48/$p.png linux/64/$p.png linux/128/$p.png
78     done
79     convert src/dcpomatic.png -resize 400x400 windows/dcpomatic.bmp
80
81     # OS X preferences icons
82     mkdir -p osx/preferences
83     for c in black white; do
84         for i in defaults email kdm_email cover_sheet keys tms notifications locations sound identifiers servers general advanced non_standard; do
85             inkbatch --inkscape $INKSCAPE -i bounds-$i -o osx/preferences/${i}_${c}.png --width 32 --height 32 src/preferences_$c.svg
86             inkbatch --inkscape $INKSCAPE -i bounds-$i -o osx/preferences/${i}@2x_${c}.png --width 64 --height 64 src/preferences_$c.svg
87         done
88     done
89
90     # OS X menu bar icon for the server (in dark and light mode)
91     $INKSCAPE_EXPORT --export-filename=osx/dcpomatic_small_white.png -w 64 -h 64 src/dcpomatic_small_white.svg
92     $INKSCAPE_EXPORT --export-filename=osx/dcpomatic_small_black.png -w 64 -h 64 src/dcpomatic_small_black.svg
93
94     # Splash screen (all platforms)
95     $INKSCAPE_EXPORT --export-filename=splash.png src/splash.svg -w 400 -h 300
96
97     # Timeline toolbar icons (all platforms)
98     for c in black white; do
99         for i in select zoom zoom_all snap sequence; do
100             inkbatch --inkscape $INKSCAPE -i timeline-$i -o ${i}_${c}.png --width 32 --height 32 src/timeline_$c.svg
101         done
102     done
103
104     # Batch converter toolbar icons (all platforms)
105     for c in black white; do
106         for i in add pause; do
107             inkbatch --inkscape $INKSCAPE -i batch-$i -o ${i}_${c}.png --width 32 --height 32 src/batch_$c.svg
108         done
109     done
110
111     # Link icon
112     for c in black white; do
113         $INKSCAPE_EXPORT --export-filename=link_$c.png src/link_$c.svg -w 9 -h 16
114     done
115
116     # favicon
117     mkdir -p web
118     convert src/web.png -resize 256x256 -transparent white web/favicon-256x256.png
119     for r in 16 32 64 128; do
120         convert web/favicon-256x256.png -resize $rx$r web/favicon-${r}x${r}.png
121     done
122     convert web/favicon-16x16.png web/favicon-32x32.png web/favicon-64x64.png web/favicon-128x128.png web/favicon-256x256.png web/favicon.ico
123     convert src/web.png -resize 123x123 -transparent white web/logo.png
124 fi