Merge pull request #1151 from mfitzp/open-http-image

Add support for HTTP response objects to Image.open()
This commit is contained in:
Alex Clark 2015-03-28 07:21:15 -04:00
commit aaa26f316a

View File

@ -109,6 +109,7 @@ from PIL._util import deferred_error
import os import os
import sys import sys
import io
# type stuff # type stuff
import collections import collections
@ -2248,6 +2249,11 @@ def open(fp, mode="r"):
else: else:
filename = "" filename = ""
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
prefix = fp.read(16) prefix = fp.read(16)
preinit() preinit()