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

Changed quantize default dither to FLOYDSTEINBERG #6068

Merged
merged 3 commits into from Feb 19, 2022

Conversation

radarhere
Copy link
Member

https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.quantize

dither – Dithering method, used when converting from mode “RGB” to “P” or from “RGB” or “L” to “1”. Available methods are NONE or FLOYDSTEINBERG (default). Default: 1 (legacy setting)

It's weird that the documentation specified twice what the default was, but I guess that the FLOYDSTEINBERG constant has a raw value of 1. Oh wait, no, it doesn't.

Pillow/src/PIL/Image.py

Lines 168 to 172 in 29b7030

# dithers
NEAREST = NONE = 0
ORDERED = 1 # Not yet implemented
RASTERIZE = 2 # Not yet implemented
FLOYDSTEINBERG = 3 # default

If you search for 'dither' in Image.py, _imaging.c and Convert.c, it makes no difference in the code whether it is 1 or 3.

So this PR suggests changing the quantize() default dither to FLOYDSTEINBERG. It should have no effect on the behaviour of Pillow, but it will stop the docstring from being confusing.

While I'm here, I also stop passing dither to the C function tobilevel, since it is unused.

@hugovk hugovk merged commit de06aba into python-pillow:main Feb 19, 2022
@radarhere radarhere deleted the quantize branch February 19, 2022 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants