summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorNullptrderef <nullptrderef@proton.me>2024-01-14 00:54:48 +0100
committerNullptrderef <nullptrderef@proton.me>2024-01-14 00:54:48 +0100
commit339c338308954ba1398612113536129720eae79b (patch)
tree87e57ed2cfb3ab6114ab08332e5a9c092d57e0eb /contrib
parentd66fd6afe13c904137398fc35d690d99f7b8be75 (diff)
downloadtaler-mdb-339c338308954ba1398612113536129720eae79b.tar.gz
taler-mdb-339c338308954ba1398612113536129720eae79b.tar.bz2
taler-mdb-339c338308954ba1398612113536129720eae79b.zip
improve conversion script to support multiple backends
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/convert-svgs-to-pngs47
1 files changed, 43 insertions, 4 deletions
diff --git a/contrib/convert-svgs-to-pngs b/contrib/convert-svgs-to-pngs
index a132794..d17136e 100755
--- a/contrib/convert-svgs-to-pngs
+++ b/contrib/convert-svgs-to-pngs
@@ -1,14 +1,53 @@
#!/bin/bash
# This file is in the public domain.
# Convert local SVGs to the PNGs for display.
+
+# Please make sure you have the relevant fonts installed - in the case of the builtin SVGs, these are the following:
+# All:
+# - Roboto (Arch: `ttf-roboto`)
+# ADs:
+# - Inter (Arch: `inter-font`)
+# - Source Sans Pro (Arch: `adobe-source-sans-fonts`)
+# Err:
+# - JetBrains Mono (Arch: `ttf-jetbrains-mono`)
+
set -eu
-for dir in err;
+
+# General Config
+echo "${CONVERSION_TOOL:=inkscape}" &> /dev/null; # Which conversion tool to use - "im" (imagemagick), "gm" (graphicsmagick, can produce weird font results) and "inkscape"
+echo "${TARGET_RESOLUTION:="768x576"}" &> /dev/null; # The final output resolution
+
+# Imagemagick/Graphicsmagick Options
+echo "${IM_SCALE_RESOLUTION:="1536x1152"}" &> /dev/null; # The resolution we set when telling magick to parse the SVG - higher than TARGET_RESOLUTION due to some blurry imagery caused by imagemagick otherwise.
+
+# Loop over every directory with imagesfor dir in err ads;
+for dir in err ads;
do
mkdir -p "${dir}/png"
+
+ if [[ "$CONVERSION_TOOL" == "inkscape" ]]; then
+ width=$(echo -n "$TARGET_RESOLUTION" | sed 's/x/ /' | awk '{print $1}')
+ height=$(echo -n "$TARGET_RESOLUTION" | sed 's/x/ /' | awk '{print $2}')
+ fi;
+
+ # Convert them
for svg in "${dir}/svg/"*;
- do
+ do
png=$(sed 's/svg/png/g' <<< "$svg");
- echo "Converting $svg to $png"
- inkscape -w 768 -h 576 "$svg" -o "$png" &> /dev/null
+ echo "Converting $svg to $png with $CONVERSION_TOOL";
+ case "$CONVERSION_TOOL" in
+ "im")
+ magick convert -density "$TARGET_RESOLUTION" "$svg" -resize "$TARGET_RESOLUTION" "$png";
+ ;;
+ "gm")
+ gm convert -density "$TARGET_RESOLUTION" "$svg" -resize "$TARGET_RESOLUTION" "$png";
+ ;;
+ "inkscape")
+ inkscape -w "$width" -h "$height" "$svg" -o "$png" &> /dev/null
+ ;;
+ *)
+ echo "FATAL: Invalid tool \"$CONVERSION_TOOL\"" 1>&2
+ ;;
+ esac;
done;
done;