Created
October 18, 2015 12:07
-
-
Save actuallymentor/89b643f03df4776112c4 to your computer and use it in GitHub Desktop.
Optimize images in a WordPress installation using Bash
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
# You need a recent version of jpegoptim and pngquant for this | |
yes | apt-get install jpegoptim | |
yes | apt-get install pngquant; | |
# Navigate to your wp-content/uploads | |
#optimize JPEG | |
optimizelossy() { jpegoptim -v *.jpg --max=80; for i in *; do if test -d $i; then cd $i; echo $i; optimizelossy; cd .. ; fi; done; echo; } | |
optimizelossy | |
# Optimize PNG | |
find . -name '*.png' -exec pngquant --quality=70-80 -f --force 256 {} \; | |
# Fix permissions | |
find . -type d -exec chmod 755 {} \; | |
find . -type f -exec chmod 644 {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment