Skip to content

Commit

Permalink
Merge pull request #5551 from radarhere/imageops
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Jun 20, 2021
2 parents 93871c0 + 6639b2a commit e5b2d61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Tests/test_imageops.py
Expand Up @@ -156,6 +156,12 @@ def test_scale():
assert newimg.size == (25, 25)


def test_expand_palette():
im = Image.open("Tests/images/hopper.gif")
im_expanded = ImageOps.expand(im)
assert_image_equal(im_expanded.convert("RGB"), im.convert("RGB"))


def test_colorize_2color():
# Test the colorizing function with 2-color functionality

Expand Down
2 changes: 2 additions & 0 deletions src/PIL/ImageOps.py
Expand Up @@ -393,6 +393,8 @@ def expand(image, border=0, fill=0):
width = left + image.size[0] + right
height = top + image.size[1] + bottom
out = Image.new(image.mode, (width, height), _color(fill, image.mode))
if image.mode == "P" and image.palette:
out.putpalette(image.palette)
out.paste(image, (left, top))
return out

Expand Down

0 comments on commit e5b2d61

Please sign in to comment.