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
Manipulating .cr2 file crashes Python process (signal 11) #3786
Comments
Testing, this became readable with #3489 On my machine, when saving I get - OJPEGSetupEncode: OJPEG encoding not supported; use new-style JPEG compression instead.
Traceback (most recent call last):
File "test.py", line 7, in <module>
im.save("new_file.tif")
File "PIL/Image.py", line 2007, in save
File "PIL/TiffImagePlugin.py", line 1564, in _save
OSError: encoder error -2 when writing image file |
I've tried to dig a little bit deeper and my code never even reaches Line 1973 in ee063af
It never comes out of |
If you're looking for an immediate workaround, I can offer you this - from PIL import Image
im = Image.open('image.CR2')
im = im.transform(im.size, Image.AFFINE, [1.0, 0.0, 0.0, 0.0, 1.0, 0.0])
im.save('out.tif') |
It seems that the process crash is specific to macOS because when running this same code and image on Debian system, everything seems to work the same way that @radarhere has described. Can't be sure but this might be related to this github issue: #3677 |
My current theory is this is related to #4034. |
Testing before #4034, I was consistently getting a segfault. Now, I am consistently getting an |
For the current form of this issue at least, the problem is that the image compression is 'tiff_jpeg'. Pillow states this is obsolete. It corresponds to OJPEG, matching the error that is seen when the code for this issue is run -
That error message comes from libtiff. So I've created PR #4627 to take the suggestion. As a workaround in the meantime, you could fix this specific situation by changing the compression manually. from PIL import Image
img = Image.open("file_1.cr2")
del img.tag_v2[700]
if img.info["compression"] == "tiff_jpeg":
img.info["compression"] = "jpeg"
img.save("new_file.tif") |
What did you do?
I was trying to open and save .cr2 image in another format.
What did you expect to happen?
I expected the file to be saved OR at least raise some kind of exception why it couldn't be done. Anything I could work with
What actually happened?
Python process crashed with the following message:
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
What are your OS, Python and Pillow versions?
In Pillow 5.4.1 this file wasn't identified by Pillow as image and so the code just skipped this part. But in 6.0.0 Pillow does identify it as image but after that things blow up.
image.CR2.zip
The text was updated successfully, but these errors were encountered: