Skip to content

Commit c62c514

Browse files
authored
Merge pull request #7187 from radarhere/putpalette
2 parents 9d08c82 + 07eccd9 commit c62c514

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Tests/test_image_putpalette.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ def palette(mode):
3232
with pytest.raises(ValueError):
3333
palette("YCbCr")
3434

35+
with Image.open("Tests/images/hopper_gray.jpg") as im:
36+
assert im.mode == "L"
37+
im.putpalette(list(range(256)) * 3)
38+
39+
with Image.open("Tests/images/la.tga") as im:
40+
assert im.mode == "LA"
41+
im.putpalette(list(range(256)) * 3)
42+
3543

3644
def test_imagepalette():
3745
im = hopper("P")

src/libImaging/Unpack.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,10 +1552,12 @@ static struct {
15521552
{"P", "P;4L", 4, unpackP4L},
15531553
{"P", "P", 8, copy1},
15541554
{"P", "P;R", 8, unpackLR},
1555+
{"P", "L", 8, copy1},
15551556

15561557
/* palette w. alpha */
15571558
{"PA", "PA", 16, unpackLA},
15581559
{"PA", "PA;L", 16, unpackLAL},
1560+
{"PA", "LA", 16, unpackLA},
15591561

15601562
/* true colour */
15611563
{"RGB", "RGB", 24, ImagingUnpackRGB},

0 commit comments

Comments
 (0)