Skip to content

Instantly share code, notes, and snippets.

@BradMcGonigle
Forked from beck/png-crush.sh
Created September 5, 2017 19:51
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 BradMcGonigle/31e2a570dc6a79106234a8232c2f93b8 to your computer and use it in GitHub Desktop.
Save BradMcGonigle/31e2a570dc6a79106234a8232c2f93b8 to your computer and use it in GitHub Desktop.
Crush the pngs
#!/bin/sh
# Cause stefano said: You can get them even smaller with
# http://www.advancemame.it/comp-readme.html after crushing
# it operates on the deflate compression, not the PNG image data
git ls-files | grep \.png$ | while read img
do
echo -n "$img..."
size_old=$(stat -f%z "$img")
advpng -q --shrink-insane --recompress "$img"
size_new=$(stat -f%z "$img")
echo $(expr $size_old - $size_new)
if [ $size_old -le $size_new ]
then
git checkout head "$img"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment