render-asset.sh
Bourne-Again shell script, ASCII text executable
1
#!/bin/bash
2
set -ueo pipefail
3
4
INKSCAPE="$(which inkscape)"
5
OPTIPNG="$(which optipng)"
6
7
SRC_FILE="assets.svg"
8
ASSETS_DIR="assets"
9
10
i="$1"
11
12
echo "Rendering '$ASSETS_DIR/$i.png'"
13
"$INKSCAPE" --export-id="$i" \
14
--export-id-only \
15
--export-png="$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null \
16
&& "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
17
18
echo "Rendering '$ASSETS_DIR/$i@2.png'"
19
"$INKSCAPE" --export-id="$i" \
20
--export-id-only \
21
--export-dpi=192 \
22
--export-png="$ASSETS_DIR/$i@2.png" "$SRC_FILE" >/dev/null \
23
&& "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i@2.png"
24