-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Corrupt JPEG data: premature end of data segment #7628
Comments
Here is the jpg_test.zip file. |
Hi. Your description of the version involved, combined with the fact that I can't replicate this with a wheel built from main, makes me think this is a duplicate of #7477, #7604 and #7625. Some users have found that libjpeg-turbo 3.0.0 causes some corruption. Our wheels only upgraded to that version with Pillow 10.0.1. The next release of Pillow, due out on January 2, will include libjpeg-turbo 3.0.1. |
I don't see any libjpeg-turbo library (.dylib) in the Pillow 10 Mac ARM PyPi distributions. It would be good to test a solution and not just wait and see. If a large fraction of the jpeg images written by Pillow since 10.0.1 (October 2023) on Mac ARM are slightly corrupted (sometimes visible in the lower right corner of images) this seems like a serious issue. |
In my test of 179 random thumbnail images 66 written by Pillow 10.1.0 were corrupted (more than 1/3). All the test images were 128 by 128 pixels in size. Not sure if the likelihood of corruption is related to the image dimensions. |
I was able to replicate the failure with a released wheel, but not with a main wheel. I've now put together wheels from main with libjpeg-turbo 3.0.0 and libjpeg-turbo 3.0.1. Testing with Python 3.8, I find that 3.0.0 fails, but 3.0.1 works. Here are wheels if you would like to test yourself. pillow-10.2.0.dev0-cp311-cp311-macosx_11_0_arm64.whl-with300.zip |
Thanks! Look forward to using the Jan 2 Pillow release. |
Pillow 10.2.0 has now been published, with libjpeg-turbo 3.0.1 in the wheels. |
Fixes #3216. Upstream issues [1] and [2]. The crucial thing is to avoid `libjpeg-turbo 3.0.0`: either either or 3.0.1 (as used in the wheels of Pillow 10.2.0). [1] python-pillow/Pillow#7625 [2] python-pillow/Pillow#7628
I tested Pillow 10.2.0 on the jpg_test.zip test case and it has fixed the problem. Thanks! |
Pillow version 10.1.0 in Python 3.11.6 on macOS 14.2.1 with ARM CPU writes corrupted JPEG files about 1/3 of the time. I've attached a zip file giving an example. The zip file contains 3 PNG images and a Python script gen.py that opens the PNG files using Pillow and saves them as JPEG images. ImageMagick 7.1.1 then reports 2 of the 3 JPEG files are corrupted.
The same corruption happens with Pillow 10.1.0 and 10.0.1 but does not happen with Pillow 10.0.0 on Mac ARM. The corruption does not happen in Intel Mac nor on Windows 11 with Pillow 10.1.0.
So it appears the bug is specific to Mac ARM Pillow 10.0.1 and 10.1.0. I see that the libjpeg*.dylib version changed in the Mac ARM Pillow in PIL/.dylibs in going from version 10.0.0 (no corruption, libjpeg.62.3.0.dylib) to version 10.0.1 and 10.1.0 (corruption with libjpeg.62.4.0.dylib).
The text was updated successfully, but these errors were encountered: