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 trying to convert various TIFF files to TIFF with LZW compression. I have now repeatedly run into TIFF files with CCITT Group 4 Fax Encoding which will make Python crash under Windows.
What did you expect to happen?
I expect an exception to be raised from the PIL TIFFImagePlugin, instead of a hard crash.
What actually happened?
On Windows, the code below with the TIFF file provided will crash the entire Python process without raising exceptions. Under WSL, an OSError is raised, however:
saving image
TIFFWriteDirectoryTagSubifd: Illegal value for SubIFD tag.
TIFFWriteDirectoryTagSubifd: Illegal value for SubIFD tag.
Traceback (most recent call last):
File "main.py", line 33, in <module>
img2tif(par_dir / "fail.tif", par_dir / "out")
File "main.py", line 27, in img2tif
im.save(str(img_out), compression="tiff_lzw") # Python crashes here
File "/home/jnik/.local/lib/python3.8/site-packages/PIL/Image.py", line 2151, in save
save_handler(self, fp, filename)
File "/home/jnik/.local/lib/python3.8/site-packages/PIL/TiffImagePlugin.py", line 1631, in _save
raise OSError(f"encoder error {s} when writing image file")
OSError: encoder error -9 when writing image file
What are your OS, Python and Pillow versions?
OS: Windows 10 Pro 2004, 19041.685 and WSL Debian (Linux 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 GNU/Linux)
I have attached both the code and the offending TIFF image here: tif_fail.zip
Note that opening the offending file in e.g. IrfanView and saving it again will fix the issue. So the TIFF file is definitely damaged somehow. I don't expect Pillow to handle the file, but rather fail more gracefully.
The text was updated successfully, but these errors were encountered:
radarhere
changed the title
Conversion of TIFF with CCITT Group 4 Fax Encoding sometimes crashes Python under Windows
Conversion of TIFF with CCITT Group 4 Fax Encoding sometimes crashes under Windows
Dec 21, 2020
What did you do?
I'm trying to convert various TIFF files to TIFF with LZW compression. I have now repeatedly run into TIFF files with CCITT Group 4 Fax Encoding which will make Python crash under Windows.
What did you expect to happen?
I expect an exception to be raised from the PIL TIFFImagePlugin, instead of a hard crash.
What actually happened?
On Windows, the code below with the TIFF file provided will crash the entire Python process without raising exceptions. Under WSL, an OSError is raised, however:
What are your OS, Python and Pillow versions?
Linux 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 GNU/Linux
)Code and further information
I have attached both the code and the offending TIFF image here: tif_fail.zip
Note that opening the offending file in e.g. IrfanView and saving it again will fix the issue. So the TIFF file is definitely damaged somehow. I don't expect Pillow to handle the file, but rather fail more gracefully.
The text was updated successfully, but these errors were encountered: