Created
September 14, 2011 11:06
-
-
Save b1/1216322 to your computer and use it in GitHub Desktop.
data uri image to base64
This file contains 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
data_uri = open("sample.png", "rb").read().encode("base64").replace("\n", "") | |
img_tag = '<img alt="sample" src="data:image/png;base64,{0}">'.format(data_uri) | |
print img_tag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment