diff --git a/Tests/images/imagedraw_rounded_rectangle_radius.png b/Tests/images/imagedraw_rounded_rectangle_radius.png new file mode 100644 index 000000000..e2acf7be1 Binary files /dev/null and b/Tests/images/imagedraw_rounded_rectangle_radius.png differ diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index 3c61833fe..1eae05383 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -895,6 +895,18 @@ def test_rounded_rectangle_joined_x_different_corners() -> None: ) +def test_rounded_rectangle_radius() -> None: + # Arrange + im = Image.new("RGB", (W, H)) + draw = ImageDraw.Draw(im, "RGB") + + # Act + draw.rounded_rectangle((25, 25, 75, 75), 24, fill="red", outline="green", width=5) + + # Assert + assert_image_equal_tofile(im, "Tests/images/imagedraw_rounded_rectangle_radius.png") + + @pytest.mark.parametrize( "xy, radius, type", [ diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py index 8bcf2d8ee..eb108ac41 100644 --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -487,7 +487,7 @@ class ImageDraw: if full_x: self.draw.draw_rectangle((x0, y0 + r + 1, x1, y1 - r - 1), fill_ink, 1) - elif x1 - r - 1 > x0 + r + 1: + elif x1 - r - 1 >= x0 + r + 1: self.draw.draw_rectangle((x0 + r + 1, y0, x1 - r - 1, y1), fill_ink, 1) if not full_x and not full_y: left = [x0, y0, x0 + r, y1]