-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
Description
It seems that PIL.ImagePalette.ImagePalette's palette argument no longer expects a palette aligned by channels, but one color after the other, i.e. RGBRGBRGB rather than RRRGGGBBB as previously.
I assume this is an unintentional breaking change as it is neither specifically mentioned in the patch notes, nor was the documentation updated. I could not find any PR or bug report on this, either (unless I missed it - I am sorry if that's the case).
If this is a bug, I hope it can actually become a feature as I personally prefer the new ordering.
Example:
import PIL.Image
import PIL.ImagePalette
p = [0, 0, 0,
255, 0, 0,
0, 255, 0]
palette = PIL.ImagePalette.ImagePalette(mode='RGB', palette=p, size=len(p))
image = PIL.Image.new('P', (100, 100), 1) # fill image with second color in the palette
image.putpalette(palette)
image.show() # Gives a blue image on 8.2.0 and a red image since 8.3.0
assert image.getpalette()[:len(p)] == p, 'This assert succeeds in 8.3.0'Cheers!
- OS: Arch Linux
- Python: 3.9
- Pillow: 8.3.0+