Skip to content

Instantly share code, notes, and snippets.

@beck
Created September 5, 2017 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save beck/5c8ad5c985e8a29b13091e11765abfc3 to your computer and use it in GitHub Desktop.
Save beck/5c8ad5c985e8a29b13091e11765abfc3 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
@beck
Copy link
Author

beck commented Sep 5, 2017

Watch out, this may mess up APNG's (why on earth we using that?... idk)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment