Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multipage TIFF operations broken #5640

Closed
juhaszp95 opened this issue Jul 27, 2021 · 13 comments
Closed

Multipage TIFF operations broken #5640

juhaszp95 opened this issue Jul 27, 2021 · 13 comments
Labels
Anaconda Issues with Anaconda's Pillow TIFF Windows

Comments

@juhaszp95
Copy link

juhaszp95 commented Jul 27, 2021

What did you do?

from PIL import Image, ImageSequence

im = Image.open("image.tif")

for i, page in enumerate(ImageSequence.Iterator(im)):
    page.save("page%d.png" % i)

What did you expect to happen?

image.tif is a 25-page TIFF file. I expected that this would save the 25 pages separately as png files. Up until Pillow 8.1.2 this works correctly, but beginning with Pillow 8.2.0 (I'm currently using 8.3.1) this seems to just break Python. Not just save, but many other operations (e.g. getpixel) also seem to produce the same issue.

What actually happened?

  • python.exe crashes without giving any errors

What are your OS, Python and Pillow versions?

OS: Windows 10
Python: 3.8.10 (as part of a standard Anaconda installation)
Pillow: 8.3.1 (as part of a standard Anaconda installation)

@radarhere
Copy link
Member

Hi. If I run your code with one of our test images, it works. Would you be able to upload the image that you're having trouble with?

@radarhere radarhere added the TIFF label Jul 27, 2021
@juhaszp95
Copy link
Author

Yes - please see below. As GitHub doesn't support adding .tif files directly, I put it in a .zip archive.

image.zip

@radarhere
Copy link
Member

I'm not able to reproduce this locally on my macOS machine. I guess this may be an issue specific to Windows/Anaconda.

@kmilos
Copy link
Contributor

kmilos commented Jul 28, 2021

Are you using libtiff + Pillow from defaults or conda-forge channels?

Works for me w/ conda-forge packages on Windows (Python 3.7.10 environment though) which are using Unix I/O, but also in mingw64 (3.9.6) which are using Win32 I/O.

If it only fails w/ Anaconda defaults packages, it would indicate that most likely their libtiff and Pillow packages are now out of sync wrt the I/O scheme... This was indeed introduced in 8.2.0.

@juhaszp95
Copy link
Author

Hi, I'm using libtiff + Pillow from the default channel (as that comes with the default Anaconda installation). Libtiff is version 4.2.0, which works fine with Pillow 8.1.2 but not with Pillow >= 8.2.0.

@kmilos
Copy link
Contributor

kmilos commented Jul 28, 2021

This is a bug for Anaconda packaging then, you can try reporting there.

Please try creating a test environment using the conda-forge channel and confirm it is working.

@juhaszp95
Copy link
Author

If I switch only libtiff to conda-forge (which upgrades it to 4.3.0 from 4.2.0) it still isn't working. If both Pillow and libtiff are installed from conda-forge, it is working (which seems surprising as pillow is the same version in both repositories). I can't seem to create an environment where only Pillow is from conda-forge but libtiff is from default...

@kmilos
Copy link
Contributor

kmilos commented Jul 28, 2021

If I switch only libtiff to conda-forge (which upgrades it to 4.3.0 from 4.2.0) it still isn't working.

Yes, because libtiff I/O scheme between default and conda-forge is now identical (Unix I/O) - this wasn't the case some time ago when default libtiff was using Win32 I/O (libtiff <= 4.1.0 or 4.0.10 I think)

If both Pillow and libtiff are installed from conda-forge, it is working (which seems surprising as pillow is the same version in both repositories)

This is not surprising because each repository might add its own specific patches to the package according to their internal policies (security critical fix, important feature bugfix until next version is released, compatibility fixes w/ other packages in that repository, enabled features, platform specifics, etc.) so they will likely differ in some subtle way even though the version is "the same". This is the case here, conda-forge disables Pillow's Win32 I/O by a patch to match their own libtiff package, while Anaconda default obviously does not, and the bug is within their repository.

See also https://conda-forge.org/docs/user/tipsandtricks.html#using-multiple-channels

@juhaszp95
Copy link
Author

juhaszp95 commented Jul 28, 2021

I see, thanks. I'll try to report it there... Specifically, what would be needed on their side? To change the recipe for Pillow on the default channel so that it matches the conda-forge channel?

@kmilos
Copy link
Contributor

kmilos commented Jul 28, 2021

Specifically, what would be needed on their side? To change the recipe for Pillow on the default channel so that it matches the conda-forge channel?

Specifically, to keep libtiff and Pillow in sync wrt to I/O scheme. How they do that is up to them.

@kmilos
Copy link
Contributor

kmilos commented Jul 30, 2021

@juhaszp95 Thanks for passing on the bug report!

@radarhere
Copy link
Member

@juhaszp95 we've established that if you use conda-forge, the latest Pillow works for you. Unless there's anything further, do you mind if we close this and leave the problem as ContinuumIO/anaconda-issues#12546?

@juhaszp95
Copy link
Author

No, not at all, I think that's right. I haven't managed to trigger a reponse from them so far, but at least conda-forge is an interim solution. Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Anaconda Issues with Anaconda's Pillow TIFF Windows
Projects
None yet
Development

No branches or pull requests

4 participants