Skip to content

Instantly share code, notes, and snippets.

@sousk
Created September 14, 2011 03:58
Show Gist options
  • Save sousk/1215824 to your computer and use it in GitHub Desktop.
Save sousk/1215824 to your computer and use it in GitHub Desktop.
Compress & base64 encode your PNG file
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