diff --git a/images_resize.sh b/images_resize.sh index 0c7575d..d159c72 100755 --- a/images_resize.sh +++ b/images_resize.sh @@ -7,8 +7,17 @@ echo "Resizing large JPGs in $(pwd)" +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" + continue + fi + # Get file size before resizing SIZE_BEFORE=$(stat -f%z "$f" 2>/dev/null || stat -c%s "$f" 2>/dev/null)