Skip to content

convert: honor dither argument with ADAPTIVE palette (#5836) - #10291

Closed
Luv-Goel wants to merge 2 commits into
python-pillow:mainfrom
Luv-Goel:main
Closed

Luv-Goel wants to merge 2 commits into
python-pillow:mainfrom
Luv-Goel:main

Conversation

@Luv-Goel

Copy link
Copy Markdown

Summary

Image.convert("P", palette=ADAPTIVE, colors=N) silently dropped the
dither argument: quantize() maps each pixel to the nearest palette entry
without dithering, then the function returned early.

Fix: build the adaptive palette via quantize(), then re-convert with the
requested dither so Floyd-Steinberg is applied.

Fixes #5836

Testing

Added Tests/test_image_convert.py::test_adaptive_convert_honors_dither
asserting NONE vs FLOYDSTEINBERG produce different histograms for an
ADAPTIVE conversion.

Checklist

)

Image.convert("P", palette=ADAPTIVE, colors=N) built the palette via
quantize(), which maps each pixel to the nearest palette entry without
dithering, then returned early -- silently dropping the dither argument.

Build the adaptive palette first, then re-convert with the requested
dither so Floyd-Steinberg is applied. Add a regression test asserting
NONE vs FLOYDSTEINBERG produce different histograms.
Copilot AI balanced review requested due to automatic review settings October 23, 2026 03:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@radarhere

Copy link
Copy Markdown
Member

Hi.

  1. Apply dither when converting/quantizing to an adaptive palette #9859 already exists as a possible solution. Did you have any thoughts on that?
  2. You can see that our CI jobs are failing with your changes.

@radarhere radarhere closed this Oct 23, 2026
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.

Inconsistent use of dithering in convert and quantize

3 participants