]> de.git.xonotic.org Git - xonotic/mediasource.git/blob - gfx/medals/render.sh
f5a9c3d001e924173693d2225663bc44c86111e5
[xonotic/mediasource.git] / gfx / medals / render.sh
1 #!/bin/sh -e
2 # TASK
3 #   Insert date, make the selected gametype symbol visible,
4 #   then render and optimize png files of the three medals.
5 #
6 # DEPENDENCIES
7 #   convert
8 #   pngquant (Reduces colors to 8bit)
9 #   optipng  (Removes unnecessary data)
10 #   advpng   (Compresses with zopfli algorithm)
11 #
12 # USAGE
13 #   $0 SIZE(2^n, optimal=64)
14 #      GAMETYPE(ca|ctf|cts|dm|dom|duel|ft|insta|ka|kh|lms|nb|ons|tdm|xonotic) \
15 #      MONTH(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC) \
16 #      YEAR(YY)
17
18
19 size="$1"
20 type="$2"
21 month="$3"
22 year="$4"
23
24
25 mkdir -p "png"
26
27
28 for num in "1" "2" "3"; do
29         svg="medal$num.svg"
30         png="png/$size-$type-$year-${month,,}-$num.png"
31
32         # Render
33         sed -e "s|width=\"64\" height=\"64|width=\"$size\" height=\"$size|" \
34                 -e "s|id=\"$type\" opacity=\"0|id=\"$type\" opacity=\"1|" \
35                 -e "s|MMM|$month|" \
36                 -e "s|YY|$year|" "$svg" |\
37                 convert -background none - "$png"
38
39         # Optimize
40         pngquant --nofs --speed 1 --quality 70-75 --skip-if-larger --force --output "$png" "$png"
41         optipng -o 5 -strip all "$png"
42         advpng --recompress --shrink-insane -i 1000 "$png"
43 done