-
-
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
Loads different pixel values on Windows vs Linux #3833
Comments
How did you install Pillow on Windows and Linux? If you are just interested in consistency, the simplest thing might be to install jpeg 6.2 on Linux. |
Pillow was installed just via I am interested in consistency, but the 6.2 jpeglib also seems pretty inaccurate, maybe it is ignoring the color profiles and the outputs are perceivably different. I tried using this conda environment on windows: https://anaconda.org/anaconda/pillow. It has version 9 jpeglib and produces results in line with what I saw on Linux. |
The Windows wheels are built with |
Will there be a fix any time soon? |
I encounter the same problem. Step to reproduce:
def image_from_data(image_data: bytes) -> Image:
buffer = io.BytesIO(image_data)
return Image.open(buffer)
# on Windows
pickle.dump(image_windows, open('image_windows.pickle', 'wb'))
# on Linux/UNIX
pickle.dump(image_linux, open('image_linux.pickle', 'wb'))
image_diff = ImageChops.logical_xor(image_windows.convert('1'), image_linux.convert('1'))
image_diff.show() Black dots mean similar, white dots means different. We've tried to use the same python version, Pillow version but the results are still the same. |
As mentioned before, the Windows wheels are built with libjpeg-turbo, the Linux wheels are not. JPEG decoders are allowed to produce slightly different results, "a maximum of one bit of difference for each pixel component" according to Wikipedia. |
For more discussion on this, see #4686 |
Closing, as the conclusion here is that there should not be an expectation for different JPEG decoders to produce the same results. If you want to ensure the same output, please ensure you are using the same version of libjpeg on both environments. If the Pillow wheel does not have the version of libjpeg that you require, then install it and try compiling Pillow from source. Compiling on Windows became easier after the opening of this issue, thanks to #4495. |
A relevant read to this is following research paper: |
What did you do?
Loaded an image and checked a pixel value.
What did you expect to happen?
Identical values on windows and linux.
What actually happened?
Values differed by a visible amount.
What are your OS, Python and Pillow versions?
Additional Debug info
The input image has an sRGB color profile.
Based on what I've read online, this is may be related to the jpeglib version. However I'm confused about how Pillow links to this dependency and uses it. I'm a little stuck as to how to make the code consistent between os + versions.
The text was updated successfully, but these errors were encountered: