mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-23 15:54:09 +03:00
Merge pull request #1151 from mfitzp/open-http-image
Add support for HTTP response objects to Image.open()
This commit is contained in:
commit
aaa26f316a
|
@ -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()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user