Forked from julianxhokaxhiu/pagespeed_optimize_images.sh
Created
December 7, 2019 11:22
-
-
Save mkrentovskiy/50bc1b948a00e88c41df5c4481a5e3b8 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 | |
| # Improved as per feedback from @pascal - https://gist.github.com/julianxhokaxhiu/c0a8e813eabf9d6d9873#gistcomment-3086462 | |
| find . -type f -name "*.png" -o -name "*.PNG" -print0 | xargs -0 -I {} optipng -nb -nc "{}" | |
| find . -type f -name "*.png" -o -name "*.PNG" -print0 | xargs -0 -I {} advpng -z4 "{}" | |
| find . -type f -name "*.png" -o -name "*.PNG" -print0 | xargs -0 -I {} pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time -ow "{}" | |
| find . -type f -name "*.jpg" -o -name "*.JPG" -print0 | xargs -0 -I {} jpegoptim -f --strip-all "{}" | |
| find . -type f -name "*.jpeg" -o -name "*.JPEG" -print0 | xargs -0 -I {} jpegoptim -f --strip-all "{}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment