Skip to content

Commit

Permalink
Merge pull request #7187 from radarhere/putpalette
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Jun 13, 2023
2 parents 9d08c82 + 07eccd9 commit c62c514
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Tests/test_image_putpalette.py
Expand Up @@ -32,6 +32,14 @@ def palette(mode):
with pytest.raises(ValueError):
palette("YCbCr")

with Image.open("Tests/images/hopper_gray.jpg") as im:
assert im.mode == "L"
im.putpalette(list(range(256)) * 3)

with Image.open("Tests/images/la.tga") as im:
assert im.mode == "LA"
im.putpalette(list(range(256)) * 3)


def test_imagepalette():
im = hopper("P")
Expand Down
2 changes: 2 additions & 0 deletions src/libImaging/Unpack.c
Expand Up @@ -1552,10 +1552,12 @@ static struct {
{"P", "P;4L", 4, unpackP4L},
{"P", "P", 8, copy1},
{"P", "P;R", 8, unpackLR},
{"P", "L", 8, copy1},

/* palette w. alpha */
{"PA", "PA", 16, unpackLA},
{"PA", "PA;L", 16, unpackLAL},
{"PA", "LA", 16, unpackLA},

/* true colour */
{"RGB", "RGB", 24, ImagingUnpackRGB},
Expand Down

0 comments on commit c62c514

Please sign in to comment.