Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
image optimization script (pngcrush & jpegtran)
#!/bin/sh
# script for optimizing images in a directory (recursive)
# pngcrush & jpegtran settings from:
# http://developer.yahoo.com/performance/rules.html#opt_images
# pngcrush
for png in `find $1 -name "*.png"`;
do
echo "crushing $png ..."
pngcrush -rem alla -reduce -brute "$png" temp.png
mv -f temp.png $png
done;
# jpegtran
for jpg in `find $1 -name "*.jpg"`;
do
echo "crushing $jpg ..."
jpegtran -copy none -optimize -perfect "$jpg" temp.jpg
mv -f temp.jpg $jpg
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.