Skip to content

Instantly share code, notes, and snippets.

@simplesessions
Last active July 5, 2017 07:55
Show Gist options
  • Save simplesessions/adb41211218125c7a46d02e2f91bba42 to your computer and use it in GitHub Desktop.
Save simplesessions/adb41211218125c7a46d02e2f91bba42 to your computer and use it in GitHub Desktop.
Recursively compress JPGs
# Ref: https://guides.wp-bullet.com/batch-optimize-jpg-lossy-linux-command-line-with-jpeg-recompress/
# Run a quality check against each image, then compress using the best settings
brew install mozjpeg
find [path/to/images] -type f -iname '*.jpg' -exec jpeg-recompress --quality medium --min 60 --method smallfry \{} \{} \;
# Remove metadata from images
brew install exiftool
find [path/to/images] -type f -iname "*.jpg" -exec exiftool -overwrite_original -all= \{} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment