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