[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-mdb] 04/07: improve conversion script to support multiple b
From: |
gnunet |
Subject: |
[taler-taler-mdb] 04/07: improve conversion script to support multiple backends |
Date: |
Sun, 14 Jan 2024 00:58:38 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository taler-mdb.
commit 339c338308954ba1398612113536129720eae79b
Author: Nullptrderef <nullptrderef@proton.me>
AuthorDate: Sun Jan 14 00:54:48 2024 +0100
improve conversion script to support multiple backends
---
contrib/convert-svgs-to-pngs | 47 ++++++++++++++++++++++++++++++++++++++++----
1 file 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;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-mdb] branch master updated (aa9c8a4 -> ab7aa24), gnunet, 2024/01/13
- [taler-taler-mdb] 01/07: move err graphics to their own dir, gnunet, 2024/01/13
- [taler-taler-mdb] 03/07: introduce initial ads, gnunet, 2024/01/13
- [taler-taler-mdb] 07/07: Merge remote-tracking branch 'origin/dev/nora/ads', gnunet, 2024/01/13
- [taler-taler-mdb] 04/07: improve conversion script to support multiple backends,
gnunet <=
- [taler-taler-mdb] 05/07: introduce initial ads, gnunet, 2024/01/13
- [taler-taler-mdb] 02/07: make conversion script able to handle multiple dis, gnunet, 2024/01/13
- [taler-taler-mdb] 06/07: pngs, gnunet, 2024/01/13