Skip to content

Apply dither when converting/quantizing to an adaptive palette - #9859

Open
83Gh0st wants to merge 1 commit into
python-pillow:mainfrom
83Gh0st:fix-adaptive-palette-dithering
Open

Apply dither when converting/quantizing to an adaptive palette#9859
83Gh0st wants to merge 1 commit into
python-pillow:mainfrom
83Gh0st:fix-adaptive-palette-dithering

Conversation

@83Gh0st

@83Gh0st 83Gh0st commented Aug 9, 2026

Copy link
Copy Markdown

Fixes #5836.

dither was silently ignored whenever no reference palette was given (e.g. im.convert("P", palette=Image.Palette.ADAPTIVE, dither=...) or plain im.quantize(dither=...)), because the underlying self.im.quantize() C call has no dithering support without an explicit reference palette. This re-converts through the computed adaptive palette when dithering is explicitly requested, so dither is honored in both convert() and quantize(). Calls that don't pass dither are unaffected.

Changes proposed in this pull request:

  • Apply dithering to Image.convert(..., palette=Palette.ADAPTIVE, dither=...)
  • Apply dithering to Image.quantize(..., dither=...) when no reference palette is given
  • Add regression tests + a release note

Fixes python-pillow#5836. dither was silently ignored whenever no reference palette was given, since the underlying quantize() has no dither support without one. Now re-converts through the computed palette when dithering is explicitly requested.
Comment thread Tests/test_image_quantize.py
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.

Inconsistent use of dithering in convert and quantize

2 participants