Load image palette into Python after converting to PA

This commit is contained in:
Andrew Murray 2025-08-15 14:37:31 +10:00
parent 092d4422d5
commit 6d974b61d6
2 changed files with 9 additions and 1 deletions

View File

@ -107,6 +107,14 @@ def test_rgba_p() -> None:
assert_image_similar(im, comparable, 20)
def test_pa() -> None:
im = hopper().convert("PA")
palette = im.palette
assert palette is not None
assert palette.colors != {}
def test_rgba() -> None:
with Image.open("Tests/images/transparent.png") as im:
assert im.mode == "RGBA"

View File

@ -1143,7 +1143,7 @@ class Image:
raise ValueError(msg) from e
new_im = self._new(im)
if mode == "P" and palette != Palette.ADAPTIVE:
if mode in ("P", "PA") and palette != Palette.ADAPTIVE:
from . import ImagePalette
new_im.palette = ImagePalette.ImagePalette("RGB", im.getpalette("RGB"))