diff --git a/Tests/images/imagedraw_wide_line_larger_than_int.png b/Tests/images/imagedraw_wide_line_larger_than_int.png new file mode 100644 index 000000000..68073ce48 Binary files /dev/null and b/Tests/images/imagedraw_wide_line_larger_than_int.png differ diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index 74b0b8ff3..9aac1a0c8 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -887,6 +887,19 @@ def test_wide_line_dot(): assert_image_similar(im, Image.open(expected), 1) +def test_wide_line_larger_than_int(): + # Arrange + im = Image.new("RGB", (W, H)) + draw = ImageDraw.Draw(im) + expected = "Tests/images/imagedraw_wide_line_larger_than_int.png" + + # Act + draw.line([(0, 0), (32768, 32768)], width=3) + + # Assert + assert_image_similar(im, Image.open(expected), 1) + + @pytest.mark.parametrize( "xy", [ diff --git a/src/libImaging/Draw.c b/src/libImaging/Draw.c index 947d7f70f..962fc42e6 100644 --- a/src/libImaging/Draw.c +++ b/src/libImaging/Draw.c @@ -669,7 +669,7 @@ ImagingDrawWideLine(Imaging im, int x0, int y0, int x1, int y1, { DRAW* draw; INT32 ink; - int dx, dy; + long dx, dy; double big_hypotenuse, small_hypotenuse, ratio_max, ratio_min; int dxmin, dxmax, dymin, dymax; Edge e[4];