Created
September 14, 2011 03:58
-
-
Save sousk/1215824 to your computer and use it in GitHub Desktop.
Compress & base64 encode your PNG file
This file contains hidden or 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
fs8=`ruby -e "print '$1'.sub(/\.png$/, '-fs8.png')"` | |
if test -e "$fs8"; then | |
rm $fs8 | |
echo "rm $fs8\n" | |
fi | |
todataURI() | |
{ | |
openssl base64 -in $fs8 | awk -v ext="png" '{ str1=str1 $0 }END{ print "data:image/"ext";base64,"str1 }' | pbcopy | |
} | |
pngquant -verbose 256 $1; | |
optipng -o7 -out $fs8 $fs8 && todataURI $1 && echo "copied $fs8\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment