-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
OSError: -2 when decoding a tiff_lzw file #4237
Comments
Could you provide the image that is causing the problem? |
Happens also with this tiff_adobe_deflate compressed mandrill.zip, so not limited to tiff_lzw... Maybe related to the combination of multiple strips w/ compression? |
Loading the mandrill image, I'm unable to replicate using Pillow 6.2.1 with Python 3.7.5 on macOS 10.15. from PIL import Image
im = Image.open('mandrill.tif')
im.load() |
On Windows it is line 1189 of tiffimageplugin.py where the problem occurs
results in n=-1 and err=-2 |
I'm also unable to replicate with 6.2.1 on AppVeyor Windows or master on GHA Windows. |
I'm now suspecting this might be due to Anaconda building against new libtiff 4.1.0... Your test is still w/ 4.0.10? Indeed, I don't see a problem if I try the wheel from pypi statically linked against 4.0.10. |
Hmm, unfortunately no, I have now tried Pillow 6.2.1 on AppVeyor Windows with libtiff 4.1.0, and I am still unable to reproduce. |
I have reproduced on a second Windows x64 machine, also set up with Anaconda... I reported the issue for the conda-forge package as conda-forge/pillow-feedstock#68 |
FWIW, I drilled down to 'IMAGING_CODEC_BROKEN` being returned from ImagingLibTiffDecode() but no idea why for now (don't think I'll manage a debug build any time soon...) |
Hello, I have same problem also.
Do you find any solution? |
conda-forge/pillow-feedstock#69 (comment) has a workaround:
|
It looks like this issue is due to libtiff-4.1.0 CMake builds on Windows now unconditionally enabling https://gitlab.com/libtiff/libtiff/commit/59eb35172f8dc9a46469ad0e4877f9c88ab796cd I built Pillow-git head against a CMake static build of libtiff-4.1.0 and get 51 test failures. Disabling |
IIUC, the |
I submitted an issue to the libtiff project: https://gitlab.com/libtiff/libtiff/issues/173 |
Trying to get windows patched up on conda-forge conda-forge/libtiff-feedstock#49 |
@cgohlke the patch definitely broke opencv on conda forge So strange, I don't know opencv does it: conda install -c conda-forge opencv libtiff=4.0 python=3.7 pillow Then: from PIL import Image
im = Image.open('hopper_lzw.tif')
im.load()
import cv2
cv2.imread('hopper_lzw.tif') both work. Now, install the unpatched 4.1 conda install libtiff=4.1=*1 PIL fails, opencv works. Now, install the patched up 4.1 conda install libtiff=4.1=*2 PIL works, opencv doesn't. |
That patch is not complete! It merely fixes/demonstrates the Pillow failures. There are other places in My solution for now is to patch tiff-4.1.0
|
thanks, I made a more thorough patch and it seems to be working with:
All previously comipled, most updated versions of the packages available on conda-forge. I'll likely try to upload the package to my own conda channel mark.harfouche |
You should be able to test the packages ending in |
I have also run into a similar problem on Windows 10, Python 3.7.6, Pillow 7.0.0. from PIL import Image
p = 'test.tif'
img = Image.open(p)
img_copy = img.copy() yields:
Is this issue still being worked on? |
i wouldn't necessarily pin so hard, but you could maybe require a specific build version? though that is more fragile. Even if i did come out with build #5, then it wouldn't necessarily fix things for you.... you would have to dependo n build 5. :/ |
Is this a common error? anaconda3\lib\site-packages\PIL\TiffImagePlugin.py", line 1182, in _load_libtiff |
can you provide the output of |
usage: conda-script.py [-h] [-V] command ... |
sorry, no
|
EDIT: Loaded the from the correct OS |
it seems to me that you are using linux. Since the original issue depends on Windows, could you please open a new issue so that them maintainers of this repo can help you get going. I don't htink you issue is related to this one. |
Sorry, I just turned on my PC and responded. Forgot that it was about a Windows issue. I edited my comment to reflex the conda list from my Windows partition. |
so there are a few things going on in your system:
I Think until the motions are going through upstream, and finally trickle down, this issue won't get fixed easily, and we will have to wait for new releases of libtiff. That is likely the easiest way. Maybe use tifffile instead? |
I guess I still don't understand the purpose of environments. Do I make a new one for each project? I just thought adding everything to base would allow me pull any module I wanted. |
generally, you want to have one for each project.
In either case, this isn't the right issue to discuss this (discussing environment was not part of the original issue). Do open an other one here, or probably on stack overflow or some other Q&A forum https://forum.image.sc/ |
Thanks, I'll learn about those issues! |
I just installed the patched version and for the moment it seems to work. Thanks, @hmaarrfk ! |
I have the same issue on windows server 2016 with pillow 7.1.2, libtif 4.1 and conda, when I downgrade to Pillow 6.2.1 and libtiff 4.0.10 the code works. from PIL import Image
image = Image.open('mytiff.tif')
image.show() OSError -2 |
@nkoerb Only libtiff 4.1.0 build h885aae3_4 or later from conda-forge channel works, not from defaults |
@kmilos thanks for the info |
How to install the patched version and uninstall the current one? |
@chibbi30j1
|
I believe so, as far as ootb Pillow wheels are concerned. @hmaarrfk conda-forge will have to re-adjust again though (either turn off Win32 I/O in Pillow > 8.2.0 with a new patch, or re-enable Win32 I/O for libtiff, Pillow, and poppler...) |
This is with pillow 6.2.1 on
Python 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 22:01:29) [MSC v.1900 64 bit (AMD64)]
Seems libtiff is found without a problem, but decoding fails:
Also note that on the second attempt I get an object back, bit if I try to convert to an array, it is filled with zeros, so issue #3863 is not really closed for me.
No problems if I use 'TIFF' or 'TIFF-FI' formats via imageio, but 'TIFF-PIL' fails with the same error.
The text was updated successfully, but these errors were encountered: