Created
December 16, 2016 19:33
-
-
Save andykillen/df5e2a63323104e32ee07c2ec08ff459 to your computer and use it in GitHub Desktop.
Run this script in the wp-content/uploads directory, first making sure you have installed jpegoptim and pngcrush. change 1920> to 3.840> if you worry about @2x retina images
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 | |
for f in $(find . -name '*.jpg' -or -name '*.JPG' -or -name '*.JPEG' -or -name '*.jpeg' -or -name '*.png'); do | |
convert "$f" -resize "1920>" "$f"; | |
filename=$(basename "$f") | |
extension="${filename##*.}" | |
echo $extension; | |
if [ $extension = "png" ]; then | |
#echo "is a PNG"; | |
pngcrush -ow -rem alla -reduce "$f"; | |
else | |
convert "$f" -quality 70 "$f"; | |
jpegoptim "$f"; | |
fi | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment