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
SRC_FILE="assets.svg"
9
ASSETS_DIR="assets"
10
11
i="$1"
12
13
echo "Rendering '$ASSETS_DIR/$i.png'"
14
if [[ -n "${RENDER_SVG}" ]]; then
15
"$RENDER_SVG" --export-id "$i" \
16
"$SRC_FILE" "$ASSETS_DIR/$i.png"
17
else
18
"$INKSCAPE" --export-id="$i" \
19
--export-id-only \
20
--export-png="$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null
21
fi
22
if [[ -n "${OPTIPNG}" ]]; then
23
"$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
24
fi
25
26
echo "Rendering '$ASSETS_DIR/$i@2.png'"
27
if [[ -n "${RENDER_SVG}" ]]; then
28
# @TODO: remove --zoom when it will be fixed/implemented in resvg
29
"$RENDER_SVG" --export-id "$i" \
30
--dpi 192 \
31
--zoom 2 \
32
"$SRC_FILE" "$ASSETS_DIR/$i@2.png"
33
else
34
"$INKSCAPE" --export-id="$i" \
35
--export-id-only \
36
--export-dpi=192 \
37
--export-png="$ASSETS_DIR/$i@2.png" "$SRC_FILE" >/dev/null
38
fi
39
if [[ -n "${OPTIPNG}" ]]; then
40
"$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i@2.png"
41
fi
42