Skip to content

Instantly share code, notes, and snippets.

@quangbahoa
Forked from vicnicius/gist:8685678
Last active December 8, 2020 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quangbahoa/65c8c0a8773aa4788a2acaac46763368 to your computer and use it in GitHub Desktop.
Save quangbahoa/65c8c0a8773aa4788a2acaac46763368 to your computer and use it in GitHub Desktop.
Script for optimizing all .jpg images inside a folder, using jpegoptim

Install first

find -type f -name "*.jpg" -exec jpegoptim --strip-all {} \;

For PNG apt-get install optipng

find -name '*.png' -print0 | xargs -0 optipng -o7

For JPG

find . -iname '*.jpg' -exec jpegoptim –max=80 –all-progressive –totals –strip-all {} \;
find . -iname '*.JPG' -exec jpegoptim –max=80 –all-progressive –totals –strip-all {} \;
find . -iname '*.jpeg' -exec jpegoptim –max=80 –all-progressive –totals –strip-all {} \;
find . -iname '*.JPEG' -exec jpegoptim –max=80 –all-progressive –totals –strip-all {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment