From 1cd916e184fe7d49c5d2e4b48e95134ac1b8b5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Sol=C3=ADs?= Date: Mon, 3 Feb 2025 03:48:12 +0000 Subject: [PATCH] fix: Make detections for GIF/WebM more precise --- friendica-fix-avatar-permissions.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/friendica-fix-avatar-permissions.sh b/friendica-fix-avatar-permissions.sh index e09e47d..46f22d9 100755 --- a/friendica-fix-avatar-permissions.sh +++ b/friendica-fix-avatar-permissions.sh @@ -22,7 +22,8 @@ loop_1(){ #Specific compression for large GIF files while [[ $(stat -c%s "${p}" || 0) -ge 512000 ]] do - nice -n 10 gifsicle "${p}" $(seq -f "#%g" 0 2 99) -O3 --lossy=80 --colors=255 -o "${p}" #&> /dev/null + frameamount=$(exiftool -b -FrameCount "${p}" || 1) + nice -n 10 gifsicle "${p}" $(seq -f "#%g" 0 2 "${frameamount}") -O3 --lossy=80 --colors=255 -o "${p}" #&> /dev/null done elif [[ "${p}" =~ .png ]] then @@ -30,7 +31,7 @@ loop_1(){ elif [[ "${p}" =~ .webp ]] then #If file is not animated - if [[ $(grep -v -q -e "ANIM" -e "ANMF" "${p}") ]] + if ! grep -v -q -e "ANIM" -e "ANMF" "${p}" then nice -n 10 cwebp -mt -af -quiet "${p}" -o /tmp/temp.webp #&> /dev/null if [[ -f /tmp/temp.webp ]]