diff --git a/Tests/test_image_convert.py b/Tests/test_image_convert.py index 33f844437..7ba3fb555 100644 --- a/Tests/test_image_convert.py +++ b/Tests/test_image_convert.py @@ -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" diff --git a/src/PIL/Image.py b/src/PIL/Image.py index b17fd131d..97a8cdfcf 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1142,7 +1142,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"))