diff --git a/PIL/ImageDraw.py b/PIL/ImageDraw.py index 7556e5ece..0e9ca832f 100644 --- a/PIL/ImageDraw.py +++ b/PIL/ImageDraw.py @@ -336,7 +336,7 @@ def floodfill(image, xy, value, border=None, thresh=0): x, y = xy try: background = pixel[x, y] - if background == value: + if _color_diff(value, background) <= thresh: return # seed point already has fill color pixel[x, y] = value except (ValueError, IndexError): diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index a3f783322..0760acd45 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -409,15 +409,15 @@ class TestImageDraw(PillowTestCase): # Arrange im = Image.new("RGB", (W, H)) draw = ImageDraw.Draw(im) - draw.rectangle(BBOX2, outline="yellow", fill="green") + draw.rectangle(BBOX2, outline="darkgreen", fill="green") centre_point = (int(W/2), int(H/2)) # Act ImageDraw.floodfill( im, centre_point, ImageColor.getrgb("red"), - thresh=100) + thresh=30) del draw - + im.save("x.png") # Assert self.assert_image_equal( im, Image.open("Tests/images/imagedraw_floodfill2.png"))