Only update Python palette if rawmode was different to the mode

This commit is contained in:
Andrew Murray 2025-11-25 23:40:34 +11:00
parent ec40c546d7
commit 6a9960e8c1

View File

@ -897,7 +897,9 @@ class Image:
else:
self.im.putpalettealphas(self.info["transparency"])
self.palette.mode = "RGBA"
else:
elif self.palette.mode != mode:
# If the palette rawmode is different to the mode,
# then update the Python palette data
self.palette.palette = self.im.getpalette(
self.palette.mode, self.palette.mode
)