You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m one of the maintainers of Loris, an image server that uses Pillow. One of our users has reported corruption of TIFF images that I believe comes from Pillow (loris-imageserver/loris#503).
importhashlibimportosimportshutilfromurllib.requestimporturlretrievefromPILimportImage# Download the imagefilename, _=urlretrieve("https://prod-elife-published.s3.amazonaws.com/digests/55692/digest-55692.tif")
# Expected size: 219528# Expected hash: 01ddb8885aa5252b41be06dcdf36703932be24436013d5ea65ca9b1fd675258aprint(f"size = {os.stat(filename).st_size}")
print(f"sha256 = {hashlib.sha256(open(filename, 'rb').read()).hexdigest()}")
# Open the image as a TIF; save as a JPEGim=Image.open(filename)
im.save("digest-55692.jpg")
This table shows the output from three versions of Pillow (resized for readability):
4.3.0
5.0.0 (next version)
7.1.2 (latest)
The corruption is not deterministic; running the script repeatedly gets images that look different every time.
Testing, I find that the problem begins with #2899, when we removed our internal TIFF LZW decoder.
Trying to look for an unusual setup in the TIFF file, I see that it has a Planar Configuration value of 2 and LZW compression. All of the test images from Pillow that I could open with Planar Configuration 2 are raw compression, so I suspect the use of compression plus separate component planes is causing the difficulty.
I’m one of the maintainers of Loris, an image server that uses Pillow. One of our users has reported corruption of TIFF images that I believe comes from Pillow (loris-imageserver/loris#503).
This example downloads the TIFF, and converts it to a JPEG (image from https://elifesciences.org/digests/55692/could-some-antibiotics-be-immune-stimulants):
This table shows the output from three versions of Pillow (resized for readability):
The corruption is not deterministic; running the script repeatedly gets images that look different every time.
I have attached a zip archive (
pillow_test_cases.zip
) which includes the original TIFF, and the three JPEG outputs.I produced these examples running inside a Docker container, built with the following Dockerfile template and varying the version of Pillow:
We've had issues with TIFFs in Loris/Pillow in the past, which led to #2926. I wonder if this issue has a similar cause?
The text was updated successfully, but these errors were encountered: