Skip to content
Discussion options

You must be logged in to vote

I will attempt to explain, let me know if there is any confusion left aftewards.

PA images do not necessarily have a palette that includes alpha values. They have two separate values for each pixel, the palette index (P) and the alpha value (A). For each 16 bit pixel, 8 bits describe the palette index (0-255) and 8 bits describe an independent alpha value. So you can combine any palette index with any alpha value.

In Pillow, palettes can be in RGBA mode, containing 256 RGBA colours. I suggest using img.putpalette(palette, 'RGBA'). See https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.putpalette. So you probably want

img = Image.fromarray(indices, mode='P')
img.p…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@radarhere
Comment options

@pekkavaa
Comment options

@radarhere
Comment options

@pekkavaa
Comment options

@radarhere
Comment options

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