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