Skip to content

Instantly share code, notes, and snippets.

@paularmstrong
Created January 9, 2015 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paularmstrong/e1637d7704a79ecf90e6 to your computer and use it in GitHub Desktop.
Save paularmstrong/e1637d7704a79ecf90e6 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Optimize PNGs
for file in `git diff --cached --name-only | grep ".png\$"`; do
echo "Crushing $file"
pngcrush -rem allb -brute -reduce $file ${file%.png}.new 2>&1 | grep "filesize"
mv -f ${file%.png}.new $file
git add $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment