diff --git a/Tests/images/imagedraw_rounded_rectangle_x_odd.png b/Tests/images/imagedraw_rounded_rectangle_x_odd.png new file mode 100644 index 00000000000..f23f1945e1f Binary files /dev/null and b/Tests/images/imagedraw_rounded_rectangle_x_odd.png differ diff --git a/Tests/images/imagedraw_rounded_rectangle_y_odd.png b/Tests/images/imagedraw_rounded_rectangle_y_odd.png new file mode 100644 index 00000000000..96441bc7289 Binary files /dev/null and b/Tests/images/imagedraw_rounded_rectangle_y_odd.png differ diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index e8a0403a51b..7497fdc66a8 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -839,7 +839,9 @@ def test_rounded_rectangle_zero_radius(bbox): "xy, suffix", [ ((20, 10, 80, 90), "x"), + ((20, 10, 81, 90), "x_odd"), ((10, 20, 90, 80), "y"), + ((10, 20, 90, 81), "y_odd"), ((20, 20, 80, 80), "both"), ], ) diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py index 1e4eeab2543..7d1790faa93 100644 --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -314,11 +314,11 @@ def rounded_rectangle( full_x, full_y = False, False if all(corners): - full_x = d >= x1 - x0 + full_x = d >= x1 - x0 - 1 if full_x: # The two left and two right corners are joined d = x1 - x0 - full_y = d >= y1 - y0 + full_y = d >= y1 - y0 - 1 if full_y: # The two top and two bottom corners are joined d = y1 - y0