Skip to content

Instantly share code, notes, and snippets.

@jorgejch
Last active August 29, 2015 14:26
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 jorgejch/a5a2c995e30c126b45a4 to your computer and use it in GitHub Desktop.
Save jorgejch/a5a2c995e30c126b45a4 to your computer and use it in GitHub Desktop.
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