From 3862180d1db116169b6dcda6c0f294f6bff8afc6 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Tue, 2 Nov 2021 07:43:58 +1000 Subject: [PATCH] Fix gfx/luma/render-svg.sh to work on debian 11 The condition of the source being newer than the destination was silently failing when the destination file did not exist It will now proceed when the destination file does not exist, and will print the reason when declining to process a file The output image was inverted with recent versions of imagemagick, same fix applied as in https://gitlab.com/xonotic/mediasource/-/merge_requests/17 --- gfx/luma/render-svg.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gfx/luma/render-svg.sh b/gfx/luma/render-svg.sh index 06fc923..8c697fe 100755 --- a/gfx/luma/render-svg.sh +++ b/gfx/luma/render-svg.sh @@ -36,7 +36,9 @@ for svg in "$@"; do dir="$data/${svg%/*}" tga="$data/${svg%.*}.tga" - if [ "$ext" = "svg" ] && [ -f "$svg" ] && [ "$svg" -nt "$tga" ]; then + # IF source file has extension .svg AND it exists AND + # destination file does NOT exist, OR source file is newer than destination file + if [ "$ext" = "svg" ] && [ -f "$svg" ] && [ ! -f "$tga" -o "$svg" -nt "$tga" ]; then echo "Rendering $tga" w=$(identify -format "%w" "$svg") @@ -44,6 +46,16 @@ for svg in "$@"; do scale=$(echo "s=sqrt($maxPixels/$w/$h);if(s>$maxScale)s=$maxScale;s" | bc) mkdir -p "$dir" - rsvg-convert -z "$scale" "$svg" | convert - -scale "$w" "$tga" + # -auto-orient works around an inversion regression present in imagemagick 6.9.11-60 + rsvg-convert -z "$scale" "$svg" | convert - -auto-orient -scale "$w" "$tga" + else + printf "NOT rendering source $svg because " + if [ ! "$ext" = "svg" ]; then + printf "file extension is not \".svg\"\n" + elif [ ! -f "$svg" ]; then + printf "file not found\n" + else + printf "$svg is not newer than $tga\n" + fi fi done -- 2.39.2