Skip to content
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

Corrected JPEG subsampling documentation #6067

Merged
merged 2 commits into from
Feb 19, 2022

Conversation

radarhere
Copy link
Member

Alternative to #4570

https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#jpeg

subsampling
If present, sets the subsampling for the encoder.

  • keep: Only valid for JPEG files, will retain the original image setting.
  • 4:4:4, 4:2:2, 4:2:0: Specific sampling values
  • -1: equivalent to keep

Discussion in that PR revealed that -1 is not always equivalent to keep. The PR suggested fixing that discrepancy by changing Pillow to make -1 equivalent to keep.

This PR instead suggests to leave Pillow behaviour unchanged, and just correct the documentation.

In Python, -1 is just the default value to pass to C.
In C, -1 is actually not a setting at all, it's just the default behaviour.
So I suggest removing -1 from the documentation. If the user wants the default behaviour, they can just not specify the subsampling option. -1 is also the default for "quality", and that isn't mentioned in the documentation.

I'm also explicitly mentioning that if subsampling is not specified, then it will be determined by the JPEG dependency.

Copy link

@QSchulz QSchulz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 thanks for taking care of that!

@hugovk hugovk merged commit e5fa767 into python-pillow:main Feb 19, 2022
@hugovk
Copy link
Member

hugovk commented Feb 19, 2022

Thank you both!

@radarhere radarhere deleted the subsampling branch March 1, 2022 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants