mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Merge pull request #5562 from radarhere/expand
Corrected border position for P mode in ImageOps.expand()
This commit is contained in:
commit
49b6dc6866
|
@ -161,7 +161,13 @@ def test_expand_palette():
|
|||
im_expanded = ImageOps.expand(im, 10, (255, 0, 0))
|
||||
|
||||
px = im_expanded.convert("RGB").load()
|
||||
assert px[0, 0] == (255, 0, 0)
|
||||
for b in range(10):
|
||||
for x in range(im_expanded.width):
|
||||
assert px[x, b] == (255, 0, 0)
|
||||
assert px[x, im_expanded.height - 1 - b] == (255, 0, 0)
|
||||
for y in range(im_expanded.height):
|
||||
assert px[b, x] == (255, 0, 0)
|
||||
assert px[b, im_expanded.width - 1 - b] == (255, 0, 0)
|
||||
|
||||
im_cropped = im_expanded.crop(
|
||||
(10, 10, im_expanded.width - 10, im_expanded.height - 10)
|
||||
|
|
|
@ -399,7 +399,7 @@ def expand(image, border=0, fill=0):
|
|||
out.paste(image, (left, top))
|
||||
|
||||
draw = ImageDraw.Draw(out)
|
||||
draw.rectangle((0, 0, width, height), outline=color, width=border)
|
||||
draw.rectangle((0, 0, width - 1, height - 1), outline=color, width=border)
|
||||
else:
|
||||
out = Image.new(image.mode, (width, height), color)
|
||||
out.paste(image, (left, top))
|
||||
|
|
Loading…
Reference in New Issue
Block a user