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.
This commit is contained in:
2026-05-01 21:51:08 -04:00
parent cc9353cd61
commit 651cccc21c
+3 -3
View File
@@ -12,9 +12,9 @@ MAX_PIXELS=8000000
find . -regextype posix-egrep -regex ".*\.(jpg|JPG|JPEG|jpeg)$" -print0 | while IFS= read -r -d '' f find . -regextype posix-egrep -regex ".*\.(jpg|JPG|JPEG|jpeg)$" -print0 | while IFS= read -r -d '' f
do do
# Check pixel count before processing # Check pixel count before processing
PIXELS=$(~/Applications/magick identify -format "%[fx:w*h]" "$f" 2>/dev/null) read -r IMG_W IMG_H < <(~/Applications/magick identify -format "%w %h" "$f" 2>/dev/null)
if [[ -n "$PIXELS" && "$PIXELS" -le "$MAX_PIXELS" ]]; then if [[ -n "$IMG_W" && -n "$IMG_H" && $((IMG_W * IMG_H)) -le "$MAX_PIXELS" ]]; then
echo "Skipping $f: ${PIXELS}px already within limit" echo "Skipping $f: ${IMG_W}x${IMG_H} already within limit"
continue continue
fi fi