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:
+3
-3
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user