Skip to content

Commit

Permalink
Copy palette in expand() for PA
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Sep 19, 2022
1 parent 279ddf4 commit 3c42b27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Tests/test_imageops.py
Expand Up @@ -130,8 +130,9 @@ def test_pad():
)


def test_palette():
im = hopper("P")
@pytest.mark.parametrize("mode", ("P", "PA"))
def test_palette(mode):
im = hopper(mode)

# Expand
expanded_im = ImageOps.expand(im)
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/ImageOps.py
Expand Up @@ -398,7 +398,7 @@ def expand(image, border=0, fill=0):
width = left + image.size[0] + right
height = top + image.size[1] + bottom
color = _color(fill, image.mode)
if image.mode == "P" and image.palette:
if image.palette:
palette = ImagePalette.ImagePalette(palette=image.getpalette())
if isinstance(color, tuple):
color = palette.getcolor(color)
Expand Down

0 comments on commit 3c42b27

Please sign in to comment.