Created
August 21, 2013 16:44
-
-
Save readingtype/6296924 to your computer and use it in GitHub Desktop.
Make a base64 encoded PNG in Python 2. The URI format for an img element's src attribute is
data:image/png;base64 followed by a comma, followed by the content of the base64 encoded text 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
import base64 | |
raw = open("path/to/image.png","rb") | |
encoded = open("path/to/image.png.base64.txt", "w") | |
encoded.write(base64.b64encode(raw.read())) | |
exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment