Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

Do not update palette for L mode GIF frame

Open radarhere opened this issue 8 months ago • 0 comments

Resolves #8921

When a GIF frame doesn't have a global palette, and an individual frame has a palette where the colours sequentially move from (0, 0, 0) to (255, 255, 255), or even if the palette is less than 256 colours in length and still follows that progression, Pillow reads that as an L mode frame.

https://github.com/python-pillow/Pillow/blob/58e48745cc7b6c6f7dd26a50fe68d1a82ea51562/src/PIL/GifImagePlugin.py#L93-L97 https://github.com/python-pillow/Pillow/blob/58e48745cc7b6c6f7dd26a50fe68d1a82ea51562/src/PIL/GifImagePlugin.py#L291-L294 https://github.com/python-pillow/Pillow/blob/58e48745cc7b6c6f7dd26a50fe68d1a82ea51562/src/PIL/GifImagePlugin.py#L315 https://github.com/python-pillow/Pillow/blob/58e48745cc7b6c6f7dd26a50fe68d1a82ea51562/src/PIL/GifImagePlugin.py#L430

GIF frames may have transparency though, and https://github.com/python-pillow/Pillow/blob/58e48745cc7b6c6f7dd26a50fe68d1a82ea51562/src/PIL/GifImagePlugin.py#L479-L480 is not able to accomodate an L mode frame with transparency.

This fixes that.

radarhere avatar Apr 23 '25 13:04 radarhere