Skip to content

Commit 3ced6ca

Browse files
authored
Load image palette into Python after converting to PA (#9152)
2 parents a2e2939 + 6d974b6 commit 3ced6ca

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Tests/test_image_convert.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ def test_rgba_p() -> None:
107107
assert_image_similar(im, comparable, 20)
108108

109109

110+
def test_pa() -> None:
111+
im = hopper().convert("PA")
112+
113+
palette = im.palette
114+
assert palette is not None
115+
assert palette.colors != {}
116+
117+
110118
def test_rgba() -> None:
111119
with Image.open("Tests/images/transparent.png") as im:
112120
assert im.mode == "RGBA"

src/PIL/Image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ def convert_transparency(
11421142
raise ValueError(msg) from e
11431143

11441144
new_im = self._new(im)
1145-
if mode == "P" and palette != Palette.ADAPTIVE:
1145+
if mode in ("P", "PA") and palette != Palette.ADAPTIVE:
11461146
from . import ImagePalette
11471147

11481148
new_im.palette = ImagePalette.ImagePalette("RGB", im.getpalette("RGB"))

0 commit comments

Comments
 (0)