mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-13 05:06:49 +03:00
Catch ValueError when processing the edge of an image
This commit is contained in:
parent
4ec322aa7d
commit
0411caba67
|
@ -366,6 +366,11 @@ class TestImageDraw(PillowTestCase):
|
||||||
ImageDraw.floodfill(im, (W, H), red)
|
ImageDraw.floodfill(im, (W, H), red)
|
||||||
self.assert_image_equal(im, im_floodfill)
|
self.assert_image_equal(im, im_floodfill)
|
||||||
|
|
||||||
|
# Test filling at the edge of an image
|
||||||
|
im = Image.new("RGB", (1, 1))
|
||||||
|
ImageDraw.floodfill(im, (0, 0), red)
|
||||||
|
self.assert_image_equal(im, Image.new("RGB", (1, 1), red))
|
||||||
|
|
||||||
def test_floodfill_border(self):
|
def test_floodfill_border(self):
|
||||||
# floodfill() is experimental
|
# floodfill() is experimental
|
||||||
|
|
||||||
|
|
|
@ -358,7 +358,7 @@ def floodfill(image, xy, value, border=None, thresh=0):
|
||||||
for (s, t) in ((x+1, y), (x-1, y), (x, y+1), (x, y-1)):
|
for (s, t) in ((x+1, y), (x-1, y), (x, y+1), (x, y-1)):
|
||||||
try:
|
try:
|
||||||
p = pixel[s, t]
|
p = pixel[s, t]
|
||||||
except IndexError:
|
except (ValueError, IndexError):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if _color_diff(p, background) <= thresh:
|
if _color_diff(p, background) <= thresh:
|
||||||
|
@ -372,7 +372,7 @@ def floodfill(image, xy, value, border=None, thresh=0):
|
||||||
for (s, t) in ((x+1, y), (x-1, y), (x, y+1), (x, y-1)):
|
for (s, t) in ((x+1, y), (x-1, y), (x, y+1), (x, y-1)):
|
||||||
try:
|
try:
|
||||||
p = pixel[s, t]
|
p = pixel[s, t]
|
||||||
except IndexError:
|
except (ValueError, IndexError):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if p != value and p != border:
|
if p != value and p != border:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user