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