From f26724da0a2f022a81bb23d83cdaf8cc45881933 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Tue, 18 Jan 2022 03:25:22 +1000 Subject: [PATCH] Work around imagemagick regression that puts everything upside down Signed-off-by: bones_was_here --- misc/tools/autoshader.sh | 2 +- misc/tools/brightspot.sh | 12 +++++------ misc/tools/cached-converter.sh | 28 ++++++++++++------------- misc/tools/compress-texture | 2 +- misc/tools/fiximage.pl | 2 +- misc/tools/rebrand-darkplaces-engine.sh | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/misc/tools/autoshader.sh b/misc/tools/autoshader.sh index 0c6c4f03..dfc4f5a8 100755 --- a/misc/tools/autoshader.sh +++ b/misc/tools/autoshader.sh @@ -147,7 +147,7 @@ has_shader() has_alpha() { - [ -f "${1%.jpg}_alpha.jpg" ] || convert "$1" -depth 8 RGBA:- | xxd -c 4 -g 1 | grep -v " ff " >/dev/null + [ -f "${1%.jpg}_alpha.jpg" ] || convert "$1" -auto-orient -depth 8 RGBA:- | xxd -c 4 -g 1 | grep -v " ff " >/dev/null } autoshaders() diff --git a/misc/tools/brightspot.sh b/misc/tools/brightspot.sh index a14b3685..e087a5a9 100755 --- a/misc/tools/brightspot.sh +++ b/misc/tools/brightspot.sh @@ -28,10 +28,10 @@ name=${name%_[rlbfud][tfktpn]} echo >&2 "Order: 0=rt 1=lf 2=bk 3=ft 4=up 5=dn" { - convert "$name"_rt."$ext" -depth 8 -geometry 512x512 GRAY:- - convert "$name"_lf."$ext" -depth 8 -geometry 512x512 GRAY:- - convert "$name"_bk."$ext" -depth 8 -geometry 512x512 GRAY:- - convert "$name"_ft."$ext" -depth 8 -geometry 512x512 GRAY:- - convert "$name"_up."$ext" -depth 8 -geometry 512x512 GRAY:- - convert "$name"_dn."$ext" -depth 8 -geometry 512x512 GRAY:- + convert "$name"_rt."$ext" -auto-orient -depth 8 -geometry 512x512 GRAY:- + convert "$name"_lf."$ext" -auto-orient -depth 8 -geometry 512x512 GRAY:- + convert "$name"_bk."$ext" -auto-orient -depth 8 -geometry 512x512 GRAY:- + convert "$name"_ft."$ext" -auto-orient -depth 8 -geometry 512x512 GRAY:- + convert "$name"_up."$ext" -auto-orient -depth 8 -geometry 512x512 GRAY:- + convert "$name"_dn."$ext" -auto-orient -depth 8 -geometry 512x512 GRAY:- } | "$brightspot" /dev/stdin diff --git a/misc/tools/cached-converter.sh b/misc/tools/cached-converter.sh index a538c709..1e8f7e9c 100755 --- a/misc/tools/cached-converter.sh +++ b/misc/tools/cached-converter.sh @@ -210,7 +210,7 @@ reduce_jpeg2_dds() i=$1; shift ia=$1; shift o=$1; shift; shift - convert "$i" "$ia" -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.tga" && \ + convert "$i" "$ia" -auto-orient -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.tga" && \ pickdxta "$dds_tool" "$dds_sepalpha" "$tmpdir/x.tga" "$o" $1 } @@ -219,7 +219,7 @@ reduce_jpeg2_dds_premul() i=$1; shift ia=$1; shift o=$1; shift; shift - convert "$i" "$ia" -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.tga" && \ + convert "$i" "$ia" -auto-orient -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.tga" && \ pickdxta "$dds_tool" "$dds_prealpha" "$tmpdir/x.tga" "$o" $1 } @@ -229,14 +229,14 @@ reduce_jpeg2_jpeg2() ia=$1; shift o=$1; shift oa=$1; shift - if convert "$i" TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then + if convert "$i" -auto-orient TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then if [ "`stat -c %s "$i"`" -lt "`stat -c %s "$o"`" ]; then cp "$i" "$o" fi else return 1 fi - if convert "$ia" TGA:- | cjpeg -targa -quality "$2" -optimize -sample 1x1,1x1,1x1 > "$oa"; then + if convert "$ia" -auto-orient TGA:- | cjpeg -targa -quality "$2" -optimize -sample 1x1,1x1,1x1 > "$oa"; then if [ "`stat -c %s "$ia"`" -lt "`stat -c %s "$oa"`" ]; then cp "$ia" "$oa" fi @@ -251,7 +251,7 @@ reduce_jpeg2_webp() ia=$1; shift o=$1; shift; shift # this one MUST run - convert "$i" "$ia" -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.png" && \ + convert "$i" "$ia" -auto-orient -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.png" && \ cwebp $1 "$tmpdir/x.png" -o "$o" } @@ -259,7 +259,7 @@ reduce_jpeg_jpeg() { i=$1; shift; shift o=$1; shift; shift - if convert "$i" TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then + if convert "$i" -auto-orient TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then if [ "`stat -c %s "$i"`" -lt "`stat -c %s "$o"`" ]; then cp "$i" "$o" fi @@ -289,7 +289,7 @@ reduce_rgba_dds() { i=$1; shift; shift o=$1; shift; shift - convert "$i" -type TrueColorMatte "$tmpdir/x.tga" && \ + convert "$i" -auto-orient -type TrueColorMatte "$tmpdir/x.tga" && \ pickdxta "$dds_tool" "$dds_sepalpha" "$tmpdir/x.tga" "$o" $1 } @@ -297,7 +297,7 @@ reduce_rgba_dds_premul() { i=$1; shift; shift o=$1; shift; shift - convert "$i" -type TrueColorMatte "$tmpdir/x.tga" && \ + convert "$i" -auto-orient -type TrueColorMatte "$tmpdir/x.tga" && \ pickdxta "$dds_tool" "$dds_prealpha" "$tmpdir/x.tga" "$o" $1 } @@ -306,12 +306,12 @@ reduce_rgba_jpeg2() i=$1; shift; shift o=$1; shift oa=$1; shift - if convert "$i" -alpha off TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then + if convert "$i" -auto-orient -alpha off TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then : else return 1 fi - if convert "$i" -alpha extract TGA:- | cjpeg -targa -quality "$2" -optimize -sample 1x1,1x1,1x1 > "$oa"; then + if convert "$i" -auto-orient -alpha extract TGA:- | cjpeg -targa -quality "$2" -optimize -sample 1x1,1x1,1x1 > "$oa"; then : else return 1 @@ -322,7 +322,7 @@ reduce_rgb_dds() { i=$1; shift; shift o=$1; shift; shift - convert "$i" -type TrueColor "$tmpdir/x.tga" && \ + convert "$i" -auto-orient -type TrueColor "$tmpdir/x.tga" && \ "$meprefix"compress-texture "$dds_tool" "$dds_noalpha" "$tmpdir/x.tga" "$o" $1 } @@ -330,7 +330,7 @@ reduce_rgb_jpeg() { i=$1; shift; shift o=$1; shift; shift - if convert "$i" TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then + if convert "$i" -auto-orient TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then : else return 1 @@ -341,7 +341,7 @@ reduce_rgba_webp() { i=$1; shift; shift o=$1; shift; shift - convert "$i" "$tmpdir/x.png" && \ + convert "$i" -auto-orient "$tmpdir/x.png" && \ cwebp $1 "$tmpdir/x.png" -o "$o" } @@ -349,7 +349,7 @@ has_alpha() { i=$1; shift; shift o=$1; shift; shift - if convert "$i" -depth 16 RGBA:- | perl -e 'while(read STDIN, $_, 8) { substr($_, 6, 2) eq "\xFF\xFF" or exit 1; } exit 0;'; then + if convert "$i" -auto-orient -depth 16 RGBA:- | perl -e 'while(read STDIN, $_, 8) { substr($_, 6, 2) eq "\xFF\xFF" or exit 1; } exit 0;'; then # no alpha : > "$o" else diff --git a/misc/tools/compress-texture b/misc/tools/compress-texture index 418d8e5c..9d4fcc13 100755 --- a/misc/tools/compress-texture +++ b/misc/tools/compress-texture @@ -50,7 +50,7 @@ esac if [ -n "$fourcchack" ]; then fourcchack_dir=`mktemp -d` - convert "$src" -fx "u*u.a" -type TrueColorMatte "$fourcchack_dir/src.$ext" + convert "$src" -auto-orient -fx "u*u.a" -type TrueColorMatte "$fourcchack_dir/src.$ext" src="$fourcchack_dir/src.$ext" fi diff --git a/misc/tools/fiximage.pl b/misc/tools/fiximage.pl index 33b389ca..8d5a7bcd 100755 --- a/misc/tools/fiximage.pl +++ b/misc/tools/fiximage.pl @@ -4,7 +4,7 @@ use strict; use warnings; # Usage: -# convert image.tga -depth 8 RGBA:- | perl fiximage.pl 72 | convert -depth 8 -size 72x56 RGBA:- output.tga +# convert image.tga -auto-orient -depth 8 RGBA:- | perl fiximage.pl 72 | convert -auto-orient -depth 8 -size 72x56 RGBA:- output.tga my ($width) = @ARGV; diff --git a/misc/tools/rebrand-darkplaces-engine.sh b/misc/tools/rebrand-darkplaces-engine.sh index c6d59ead..105e58cd 100755 --- a/misc/tools/rebrand-darkplaces-engine.sh +++ b/misc/tools/rebrand-darkplaces-engine.sh @@ -73,7 +73,7 @@ for EXECUTABLE in "$@"; do cp "$icon_xpm" "$t/darkplaces-icon.xpm" cnt= for i in $icons_tga; do - convert "$i" "$t/darkplaces-icon$cnt.tga" + convert "$i" -auto-orient "$t/darkplaces-icon$cnt.tga" if [ -z "$cnt" ]; then cnt=2 else -- 2.39.2