Forked from julianxhokaxhiu/pagespeed_optimize_images.sh
Last active
September 22, 2020 03:27
-
-
Save mkormendy/bec8c87471df0d1a2eb9e95fd986d171 to your computer and use it in GitHub Desktop.
Recursively optimize all PNG and JPG files from the location of the script.
This file contains 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 /uploads/sites/*/20* -type f -iname "*.png" -exec pngquant --speed 1 --skip-if-larger --strip {} \; | |
find /uploads/sites/*/20* -type f -iname "*.png" -exec advpng -z4 {} \; | |
find /uploads/sites/*/20* -type f -iregex .*\.jpe?g$ -exec jpegoptim -f -s -v -m 50 {} \; | |
touch optimg.flag | |
# find's -newer command option compares the timestamps of files found against a defined file, in our case optimg.flag | |
# when we finish optimizing all of the images we touch the optimg.flag file to update its timestamp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment