Image.remap_palette bug? #6389
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hmm. I initially thought it wasn't fixed by Image.putpalette, but I just realized that that was because I forgot to remove the manual specification of the palette on save. Apparently this issue is related to specifying the palette during save. This might still be a bug, though not the bug I thought. Using putpalette and then not specifying a palette on save does not cause this problem. |
Beta Was this translation helpful? Give feedback.
-
The docstring states that https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.remap_palette
To break it down, As for So what about the missing colors when you run your code? import numpy as np
from pathlib import Path
palette = np.frombuffer(Path("palette.bin").read_bytes(), np.uint8).reshape((-1, 3))
print(palette) gives
The bug you have found is not in |
Beta Was this translation helpful? Give feedback.
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
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…