diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py index 367ba7e3e..1051d9843 100644 --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -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) diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py index 99f10d739..57a032c94 100644 --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -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)