Skip to content

Instantly share code, notes, and snippets.

@carlosmcevilly
Created October 16, 2011 05:54
Show Gist options
  • Save carlosmcevilly/1290557 to your computer and use it in GitHub Desktop.
Save carlosmcevilly/1290557 to your computer and use it in GitHub Desktop.
script create an img tag with data for a given .png image file
#!/bin/bash
# create an <img src=""> tag with data for a given .png image file
export in=$1
if [[ "$in" == '' ]]; then
echo "usage: $0 infile"
exit -1
fi
echo -n '<img src="data:image/png;base64,'
openssl enc -base64 -in $in | perl -p -e 's/\n//' -
echo '">'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment