Skip to content

Set all transparent colors to be equal in quantize()#5282

Merged
hugovk merged 1 commit intopython-pillow:masterfrom
radarhere:quantize
Mar 31, 2021
Merged

Set all transparent colors to be equal in quantize()#5282
hugovk merged 1 commit intopython-pillow:masterfrom
radarhere:quantize

Conversation

@radarhere
Copy link
Copy Markdown
Member

@radarhere radarhere commented Feb 25, 2021

When quantize() converts an RGBA image to P mode, it currently translates two pixels with full transparency as different if they have different RGB values. This PR sets all transparent pixels to have the same RGB values as the first transparent pixel, so that they all end up with the same P value.

This improvement is also helpful when it comes to GIFs, which can only mark one color in the palette as transparent. This resolves the second part of #3603

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.

2 participants