Last active
August 29, 2015 14:26
-
-
Save jorgejch/a5a2c995e30c126b45a4 to your computer and use it in GitHub Desktop.
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
import base64 | |
import cStringIO | |
import PIL.Image | |
''' | |
From: | |
http://stackoverflow.com/questions/31410525/base64-uri-to-png-python | |
http://stackoverflow.com/questions/3715493/encoding-an-image-file-with-base64 | |
http://effbot.org/imagingbook/image.htm | |
''' | |
with open("image.png", "rb") as image_file: | |
encoded_string = base64.b64encode(image_file.read()) | |
image_bytes = cStringIO.StringIO(encoded_string.decode('base64')) | |
img = PIL.Image.open(image_bytes) | |
img.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment