-
-
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
Exceptions with specific TIF files #6008
Comments
Hi. For your first case, the problem is that even if I do add 34712 to For your second case, the casting was added by #4103. Line 3006 in eccd853
UnidentifiedImageError . So I'm not following why a SyntaxError would make any difference to you?
|
Hi radarhere, Thank you for the kind response. For case 1 then, it perhaps will remain a limitation and I can live with that. For case 2, I can confirm that for PIL 9.0.0 on python 3.8.10, a TypeError is raised and not an UnidentifiedImageError. I did in fact handle UnidentifiedImageError exception to handle other edge cases, but in this specific case, PIL did not report the problem as such. For now, I will extend my code to support IndexError and struct.error and treat it as an UnidentifiedImageError. Thanks much for your time and consideration to this problem. |
It returns Ok. So is that all that you were after then? |
That would be correct, assuming the outer function is the one calling _open_core (which in my case is ImageSequence.Iterator) |
It's being called here Lines 3017 to 3021 in 5a8ad4e
as part of Image.open .
|
Closing, unless there are further comments or questions. Without a specific image to discuss for case 2, I don't think there's anything to be done. The width of an image is a crucial piece of information, and without it, it doesn't sound surprising that the image cannot be read. |
What did you do?
Used PIL Image, ImageSequence classes in python to load and process a .tif file.
Case (1)
This specific file is titled "MultipleFormats.tif" and is available at:
https://www.leadtools.com/support/forum/posts/t10960-
This TIF file contains JPG2000 compression on its third page. It is here that the code fails
Case(2) Tried other files that were converted using online pdf to tiff converters. Sorry, I do not have these files handy
What did you expect to happen?
Process all the pages of the given TIFF file
What actually happened?
Case (1)
Exception when reading from COMPRESSION list in TiffImagePlugin -> _setup() -> Line 1259. JPEG2000 compression key is 34712, which is not defined in COMPRESSION list causing a "keyerror" 34712
Case (2)
With other test files, I noticed that: TiffImagePlugin -> _setup() is failing in line 1280 with typecasting error, as the get() method below returned "None"
x_size = int(self.tag_v2.get(IMAGEWIDTH))
If a SyntaxError can be raised for this situation instead of optimistically typecasting to int(), it would not break the code and I can handle it in my exception handler in the calling code
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: