From b3ea34fb88b4b7b5dbde2a988c5bc99df9f9179c Mon Sep 17 00:00:00 2001 From: Alex Clark Date: Sat, 28 Mar 2015 07:22:14 -0400 Subject: [PATCH] Document #1151 [ci skip] --- docs/releasenotes/2.7.0.rst | 4 ++-- docs/releasenotes/2.8.0.rst | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 docs/releasenotes/2.8.0.rst diff --git a/docs/releasenotes/2.7.0.rst b/docs/releasenotes/2.7.0.rst index 8359bd7aa..65a8f2d11 100644 --- a/docs/releasenotes/2.7.0.rst +++ b/docs/releasenotes/2.7.0.rst @@ -1,5 +1,5 @@ -Pillow 2.7.0 -============ +2.7.0 +===== Sane Plugin ----------- diff --git a/docs/releasenotes/2.8.0.rst b/docs/releasenotes/2.8.0.rst new file mode 100644 index 000000000..5fe485875 --- /dev/null +++ b/docs/releasenotes/2.8.0.rst @@ -0,0 +1,14 @@ +2.8.0 +===== + +Open HTTP response objects with Image.open +------------------------------------------ + +HTTP response objects returned from `urllib2.urlopen(url)` or `requests.get(url, stream=True).raw` are 'file-like' but do not support `.seek()` operations. As a result PIL was unable to open them as images, requiring a wrap in `cStringIO` or `BytesIO`. + +Now new functionality has been added to `Image.open()` by way of an `.seek(0)` check and catch on exception `AttributeError` or `io.UnsupportedOperation`. If this is caught we attempt to wrap the object using `io.BytesIO` (which will only work on buffer-file-like objects). + +This allows opening of files using both `urllib2` and `requests`, e.g.:: + + Image.open(urllib2.urlopen(url)) + Image.open(requests.get(url, stream=True).raw)