From 651cccc21c519b2243c11d22e9adcf3d5c23afbb Mon Sep 17 00:00:00 2001 From: jim kolpack Date: Fri, 1 May 2026 21:51:08 -0400 Subject: [PATCH] Fix pixel check to use integer width/height instead of fx expression The fx:w*h format returned floats in scientific notation which broke bash arithmetic comparison. Read %w and %h separately instead. --- images_resize.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/images_resize.sh b/images_resize.sh index d159c72..4fd000b 100755 --- a/images_resize.sh +++ b/images_resize.sh @@ -12,9 +12,9 @@ MAX_PIXELS=8000000 find . -regextype posix-egrep -regex ".*\.(jpg|JPG|JPEG|jpeg)$" -print0 | while IFS= read -r -d '' f do # Check pixel count before processing - PIXELS=$(~/Applications/magick identify -format "%[fx:w*h]" "$f" 2>/dev/null) - if [[ -n "$PIXELS" && "$PIXELS" -le "$MAX_PIXELS" ]]; then - echo "Skipping $f: ${PIXELS}px already within limit" + read -r IMG_W IMG_H < <(~/Applications/magick identify -format "%w %h" "$f" 2>/dev/null) + if [[ -n "$IMG_W" && -n "$IMG_H" && $((IMG_W * IMG_H)) -le "$MAX_PIXELS" ]]; then + echo "Skipping $f: ${IMG_W}x${IMG_H} already within limit" continue fi