From 30a14eb21c4e5a7818a12632568308c57b957ccb Mon Sep 17 00:00:00 2001 From: Bas Dado Date: Wed, 1 Apr 2026 17:03:41 +0200 Subject: [PATCH] [FIX] Fixed bug where the similarity check would run on the compressed image vs the original one, giving a highe-than expected difference. We now only compress the image after a new one has been selected --- screenshot.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/screenshot.sh b/screenshot.sh index 95da5f4..3e874fe 100755 --- a/screenshot.sh +++ b/screenshot.sh @@ -68,13 +68,13 @@ then else # If cwebp is available, convert the new screenshot to webp format and delete the original png if command -v cwebp > /dev/null; then - WIDTH=$(identify -format "%w" $SCR_NEW) + WIDTH=$(identify -format "%w" $SCR_LAST) TARGET_WIDTH=$(( WIDTH * ${SCALE%%%} / 100 )) - echo "Converting $SCR_NEW to webp format with target width $TARGET_WIDTH" - # I tried some different cwebp options (-preset text/picture), -m 6), but default seems to give the best results especially given runtime. - cwebp -quiet -resize $TARGET_WIDTH 0 $SCR_NEW -o "${SCR_NEW%.png}.webp" - rm $SCR_NEW - SCR_NEW="${SCR_NEW%.png}.webp" + echo "Converting $SCR_LAST to webp format with target width $TARGET_WIDTH" + # I tried some different cwebp options (-preset text/picture), -m 6), but default seems to give the best results especially given that it's fast. + cwebp -quiet -resize $TARGET_WIDTH 0 $SCR_LAST -o "${SCR_LAST%.png}.webp" + rm $SCR_LAST + SCR_LAST="${SCR_LAST%.png}.webp" else # If cwebp is not available, we can still reduce the size of the png by resizing it with mogrify mogrify -scale $SCALE $SCR_LAST