This was originally spotted while debugging failing tests in loris-imageserver/loris#364.
What did you do?
Load a valid WEBP image by using ImageFile.Parser. I expect the Parser to read the image without raising an exception – instead, it raises an IOError "image was incomplete".
What versions of Pillow and Python are you using?
I can reproduce the issue with Pythons 2.7.13 and 3.6.1, in both cases with Pillow 4.3.0:
$ pip freeze
olefile==0.44
Pillow==4.3.0
Sample reproduction
I'm using a sample image 1.webp, downloaded from Google’s WebP gallery. A copy is also attached to the issue (compressed, because GitHub doesn't support WebP).
By my reckoning, this is an in-spec WebP image:
$ identify 1.webp
Decoded /var/folders/jy/351n9lnj5l3f07rtf2xybxx00000gn/T/magick-223024t3-o47WaC8o. Dimensions: 550 x 368 . Format: lossy. Now saving...
Saved file /var/folders/jy/351n9lnj5l3f07rtf2xybxx00000gn/T/magick-22302pw3OQD5DHOLd
1.webp PAM 550x368 550x368+0+0 8-bit TrueColor sRGB 810KB 0.000u 0:00.009
$ shasum 1.webp
0c03dcd19f804a559bd0ae32db2998dad4a4936a 1.webp
The following code reliably triggers the error:
#!/usr/bin/env python
# -*- encoding: utf-8
from PIL.ImageFile import Parser
p = Parser()
p.feed(open('1.webp', 'rb').read())
p.close()
with the following traceback:
Traceback (most recent call last):
File "pillow_webp.py", line 8, in <module>
p.close()
File "/Users/alexwlchan/.virtualenvs/tempenv-2005296845a12/lib/python3.6/site-packages/PIL/ImageFile.py", line 438, in close
raise IOError("image was incomplete")
OSError: image was incomplete
The following code does not trigger an error, but proves that Pillow is capable of processing the image correctly, as it produces a valid JPEG which matches Google’s test image:
#!/usr/bin/env python
# -*- encoding: utf-8
from PIL import Image
im = Image.open('1.webp')
im.save('1.jpg')
The issue was originally spotted with a WebP image that Pillow itself had created – a source JPEG image was being saved as WebP, then re-fed to Parser(). I can elaborate if it's useful, but that could go wrong if Pillow crashes in the Parser or if Pillow is writing bad WebP images – and I prefer the repro with Google's test image, because I think it rules out the latter.
Attachments
1.webp.zip
This was originally spotted while debugging failing tests in loris-imageserver/loris#364.
What did you do?
Load a valid WEBP image by using
ImageFile.Parser. I expect the Parser to read the image without raising an exception – instead, it raises an IOError "image was incomplete".What versions of Pillow and Python are you using?
I can reproduce the issue with Pythons 2.7.13 and 3.6.1, in both cases with Pillow 4.3.0:
Sample reproduction
I'm using a sample image
1.webp, downloaded from Google’s WebP gallery. A copy is also attached to the issue (compressed, because GitHub doesn't support WebP).By my reckoning, this is an in-spec WebP image:
The following code reliably triggers the error:
with the following traceback:
The following code does not trigger an error, but proves that Pillow is capable of processing the image correctly, as it produces a valid JPEG which matches Google’s test image:
The issue was originally spotted with a WebP image that Pillow itself had created – a source JPEG image was being saved as WebP, then re-fed to
Parser(). I can elaborate if it's useful, but that could go wrong if Pillow crashes in the Parser or if Pillow is writing bad WebP images – and I prefer the repro with Google's test image, because I think it rules out the latter.Attachments
1.webp.zip