render-asset.sh
Bourne-Again shell script, ASCII text executable
1
#!/bin/bash
2
set -ueo pipefail
3
4
RENDER_SVG="$(command -v rendersvg)" || true
5
INKSCAPE="$(command -v inkscape)" || true
6
OPTIPNG="$(command -v optipng)" || true
7
8
if "$INKSCAPE" --help | grep -e "--export-png" > /dev/null; then
9
EXPORT_FILE_OPTION="--export-png"
10
else
11
EXPORT_FILE_OPTION="--export-file"
12
fi
13
14
i="$1"
15
16
echo "Rendering '$i.png'"
17
if [[ -n "${RENDER_SVG}" ]]; then
18
"$RENDER_SVG" --dpi 96 "$i.svg" "$i.png"
19
else
20
"$INKSCAPE" --export-dpi=96 "$EXPORT_FILE_OPTION"="$i.png" "$i.svg" >/dev/null
21
fi
22
23
if [[ -n "${OPTIPNG}" ]]; then
24
"$OPTIPNG" -o7 --quiet "$i.png"
25
fi
26