Forked from julianxhokaxhiu/pagespeed_optimize_images.sh
Last active
December 11, 2018 02:38
-
-
Save krakster/440cb6c9fc152721ca9daa581faa4134 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 | |
| # optimize only fresh files, to use it with cron | |
| MTIME=1 | |
| find . -type f -mtime -$MTIME -name "*.png" -o -name "*.PNG" | xargs optipng -nb -nc | |
| find . -type f -mtime -$MTIME -name "*.png" -o -name "*.PNG" | xargs advpng -z4 | |
| find . -type f -mtime -$MTIME -name "*.png" -o -name "*.PNG" | xargs pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time -ow | |
| find . -type f -mtime -$MTIME -name "*.jpg" -o -name "*.JPG" | xargs jpegoptim -f --strip-all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment