Skip to content

Instantly share code, notes, and snippets.

@agarzon
Last active December 15, 2021 14:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save agarzon/a56563e6f7ed6fb7b3ff to your computer and use it in GitHub Desktop.
Save agarzon/a56563e6f7ed6fb7b3ff to your computer and use it in GitHub Desktop.
JPG recursive resize and compress (Linux)
#find . -type f -name '*.png' -exec optipng -o5 -quiet -preserve {} \;
#find . -type f -name '*.jp*' -exec mogrify -compress jpeg -quality 70 {} \;
find . -type f -iname "*.jp*g" | xargs mogrify -resize '1280x1280>'
find . -type f -iname "*.jp*g" | xargs jpegoptim --strip-all --max=90
# With parallel
find . -type f -iname "*.jp*g" -print0 | parallel --progress -0 -j +0 "mogrify -resize 1280x1280\> {}"
find . -type f -iname "*.jp*g" | parallel --progress "jpegoptim --strip-all --max=65 {}"
find . -type f -iname "*.jp*g" -print0 | xargs -0 -n1 -P4 jpegoptim --strip-all --force --quiet --max=85 {}
find . -type f -iname "*.png" -print0 | xargs -0 -n1 -P4 optipng -o5 -quiet -preserve {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment