Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
#!/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
You can’t perform that action at this time.