Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save kbihler/8e2e13c96032f740df788665596252b2 to your computer and use it in GitHub Desktop.

Select an option

Save kbihler/8e2e13c96032f740df788665596252b2 to your computer and use it in GitHub Desktop.
Recursively optimize all PNG and JPG files wherever they are from the script position and inner ( based on OPTING and JPEGOPTIM )
#!/bin/bash
find . -type f -name "*.png" -o -name "*.PNG" | xargs optipng -nb -nc
find . -type f -name "*.jpg" -o -name "*.JPG" | xargs jpegoptim -f --strip-all
find . -type f -name "*.jpeg" -o -name "*.JPEG" | xargs jpegoptim -f --strip-all
find . -type f -name "*.gif" | xargs gifsicle --batch -V -O2
find . -type f -name "*.svg" -print0 | xargs -0 -n 1 -P 6 svgo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment