Skip to content

Commit 0b5c150

Browse files
authored
Merge pull request #6497 from radarhere/convert
2 parents 762c29c + 7d35d70 commit 0b5c150

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Tests/test_image_convert.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ def test_p2pa_alpha():
236236
assert im_a.getpixel((x, y)) == alpha
237237

238238

239+
def test_p2pa_palette():
240+
with Image.open("Tests/images/tiny.png") as im:
241+
im_pa = im.convert("PA")
242+
assert im_pa.getpalette() == im.getpalette()
243+
244+
239245
def test_matrix_illegal_conversion():
240246
# Arrange
241247
im = hopper("CMYK")

src/libImaging/Convert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ frompalette(Imaging imOut, Imaging imIn, const char *mode) {
12431243
if (!imOut) {
12441244
return NULL;
12451245
}
1246-
if (strcmp(mode, "P") == 0) {
1246+
if (strcmp(mode, "P") == 0 || strcmp(mode, "PA") == 0) {
12471247
ImagingPaletteDelete(imOut->palette);
12481248
imOut->palette = ImagingPaletteDuplicate(imIn->palette);
12491249
}

0 commit comments

Comments
 (0)