Merge pull request #5551 from radarhere/imageops

This commit is contained in:
Hugo van Kemenade 2021-06-20 15:51:21 +03:00 committed by GitHub
commit e5b2d61e00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -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

View File

@ -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