Skip to content

Instantly share code, notes, and snippets.

@max
Created July 25, 2013 04:57
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 max/6077009 to your computer and use it in GitHub Desktop.
Save max/6077009 to your computer and use it in GitHub Desktop.

Sometimes you just want to base 64 encode an image or a font file:

function 64enc() {
  openssl base64 -in $1 | awk -v ext="${1#*.}" '{ str1=str1 $0 }END{ print "background:url(data:image/"ext";base64,"str1");" }'|pbcopy
	echo "$1 encoded to clipboard"
}
function 64font() {
  openssl base64 -in $1 | awk -v ext="${1#*.}" '{ str1=str1 $0 }END{ print "src:url(\"data:font/"ext";base64,"str1"\")  format(\"woff\");" }'|pbcopy
	echo "$1 encoded as font and copied to clipboard"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment