Last active
August 2, 2018 05:23
-
-
Save mrnonz/4f872ee491999822fac3160b6c840929 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, PNGCRUSH, ADVANCECOMP and JPEGOPTIM )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
find . -type f -name "*.png" -o -name "*.PNG" | xargs optipng -nb -nc | |
find . -type f -name "*.png" -o -name "*.PNG" | xargs advpng -z4 | |
find . -type f -name "*.png" -o -name "*.PNG" | xargs pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time -ow | |
find . -type f -name "*.jpg" -o -name "*.JPG" | xargs jpegoptim -f --strip-all | |
## Log to file | |
# find . -type f -iname "*.png" -print0 | xargs -I {} -0 optipng -o5 -quiet -keep -preserve -log optipng.log "{}" |
Crontab for run every 5th minutes.
*/5 * * * * find /path/to/images/directory/ -mmin -5 -type f -name "*.jpg" -o -name "*.JPG" | xargs jpegoptim -m70 -f --strip-all -p \; > /dev/null
How to resize image with same quality
find . -type f -size +1M | xargs -i{} convert -resize 50% {} {}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you wish to compress some file in 5 minute with 70% max quality just type like below