Skip to content

Commit

Permalink
Merge pull request #1151 from mfitzp/open-http-image
Browse files Browse the repository at this point in the history
Add support for HTTP response objects to Image.open()
  • Loading branch information
aclark4life committed Mar 28, 2015
2 parents 860a1de + 735d342 commit aaa26f3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions PIL/Image.py
Expand Up @@ -109,6 +109,7 @@ def __getattr__(self, id):

import os
import sys
import io

# type stuff
import collections
Expand Down Expand Up @@ -2248,6 +2249,11 @@ def open(fp, mode="r"):
else:
filename = ""

try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())

prefix = fp.read(16)

preinit()
Expand Down

0 comments on commit aaa26f3

Please sign in to comment.