Or. half baked. We 'support' a mode called `PA` which is palette with alpha, stored in 4 bytes per pixel. (FWIW, I think this all applies to `LA` as well) `Image.putpalette` (https://github.com/python-pillow/Pillow/blob/master/PIL/Image.py#L1447) only allows for `L` or `P` images when adding a palette: ``` if self.mode not in ("L", "P"): raise ValueError("illegal image mode") ``` `_imaging.c:_putpalette` Also only accepts\* `L` and `P`. This code was in PIL: ``` if (strcmp(self->image->mode, "L") != 0 && strcmp(self->image->mode, "P")) { PyErr_SetString(PyExc_ValueError, wrong_mode); return NULL; ``` \* or rather, it looks like it should but only actually accepts if `mode ==`P`and mode !='L'` `TiffImagePlugin:_setup` (https://github.com/python-pillow/Pillow/blob/master/PIL/TiffImagePlugin.py#L1137) only includes the palette for `P` images. ``` if self.mode == "P": palette = [o8(b // 256) for b in self.tag_v2[COLORMAP]] self.palette = ImagePalette.raw("RGB;L", b"".join(palette)) ``` All of this found while checking out #1597.
Activity
[-]PA mode handling is wonky.[/-][+]PA mode handling is wonky[/+]radarhere commentedon Mar 19, 2019
I've created PR #3728 to help this.
While I don't understand this comment, it does pass tests.
radarhere commentedon May 18, 2019
I've created PR #3848 to resolve this.