Created
July 20, 2011 16:42
-
-
Save neclimdul/1095321 to your computer and use it in GitHub Desktop.
Quick script built to compress and prep pngs for websites using pngcrush and optipng
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 | |
function compress { | |
echo "Crushing $1" | |
pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB $1 compressed/$1 > /dev/null | |
mv compressed/$image ./ | |
echo "Compressing $1" | |
optipng -o9 $1 > /dev/null | |
} | |
if [ -z "$*" ] | |
then | |
echo 'Please pass a list of pngs to compress.'; | |
fi | |
# TODO only make and remove compress if its not there. | |
mkdir compressed | |
for image in "$@" # Doesn't work properly if "$*" isn't quoted. | |
do | |
compress $image | |
done | |
# cleanup compress directory. | |
rm -r compressed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment