Skip to content

Image.remap_palette bug? #6389

Answered by radarhere
TheRealQuantam asked this question in Q&A
Discussion options

You must be logged in to vote

remap_palette cannot map multiple palette entries to the same entry. That's not a bug, it's a limitation of the concept.

The docstring states that https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.remap_palette

[1,0] would swap a two item palette, and list(range(256)) is the identity transform.

To break it down,
[1,0] - pixels with a palette index of 1 should become 0, and pixels with a palette index of 0 should become 1.
list(range(256)) - pixels with a palette index of 0 should become 0, ..., pixels with a palette index of 255 should become 255.

As for
[1, 1] - pixels with a palette index of 1 should become 0, and... pixels with a palette index of 1 should b…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@radarhere
Comment options

Answer selected by radarhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants