-
-
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
Image.tobytes() output is platform-dependent #5190
Comments
This is very likely a duplicate of #3833 / #4686. In summary, wheels for the two systems use a different JPEG library (libjpeg-turbo on Windows and libjpeg elsewhere). Due to the lossy encoding, JPEG decoders are allowed to differ slightly between different libraries, which produces the difference you are seeing. |
Alright! Thanks for the explanation, and for pointing me to those issues I did not find :) As far as I'm concern, this can be closed then. |
If that seems useful to you, I can submit a PR to explictely mentions that in |
The explanation being provided is that the JPEG data is being loaded differently, not that it is being saved differently - nothing to do with
|
To me, @nulano answers seems to the point: if JPEG decoders differ slightly, the resulting decompressed picture may have slightly different pixels, and hence |
What did you do?
My minimal reproduction code:
The test image used comes from here: https://github.com/alexanderankin/pyfpdf/blob/master/test/image/image_types/insert_images_insert_jpg.jpg
What did you expect to happen?
I expected a consistent output of this program, however, when I execute this on my Windows 10 computer, I get:
While when I run it inside the latest
python
Docker image, I get:What actually happened?
The output of the
Image.bytes()
method seems dependent of the environment.What are your OS, Python and Pillow versions?
Before even thinking about a fix, I'm mainly looking for an explanation on this inconsistent behaviour:
what causes this variation?
The text was updated successfully, but these errors were encountered: