Skip to content

Instantly share code, notes, and snippets.

@neclimdul
Created July 20, 2011 16:42
Show Gist options
  • Save neclimdul/1095321 to your computer and use it in GitHub Desktop.
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
#!/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