From 2128d6465c7fb054149b58be29fa44d892bce2de Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 27 Apr 2026 19:51:05 +1000 Subject: [PATCH 1/2] Do not draw line or arc if width is zero --- src/PIL/ImageDraw.py | 6 +++--- src/_imaging.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py index 9b0864d1a89..66511697a93 100644 --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -175,7 +175,7 @@ def arc( ) -> None: """Draw an arc.""" ink, fill = self._getink(fill) - if ink is not None: + if ink is not None and width != 0: self.draw.draw_arc(xy, start, end, ink, width) def bitmap( @@ -235,12 +235,12 @@ def line( self, xy: Coords, fill: _Ink | None = None, - width: int = 0, + width: int = 1, joint: str | None = None, ) -> None: """Draw a line, or a connected sequence of line segments.""" ink = self._getink(fill)[0] - if ink is not None: + if ink is not None and width != 0: self.draw.draw_lines(xy, ink, width) if joint == "curve" and width > 4: points: Sequence[Sequence[float]] diff --git a/src/_imaging.c b/src/_imaging.c index 980f827ae78..808112d57bb 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -3182,7 +3182,7 @@ _draw_lines(ImagingDrawObject *self, PyObject *args) { return NULL; } - if (width <= 1) { + if (width == 1) { double *p = NULL; for (i = 0; i < n - 1; i++) { p = &xy[i + i]; From 894c5d533579d12b63264920f8fc968901204665 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 7 May 2026 19:48:08 +1000 Subject: [PATCH 2/2] Width is always provided --- src/_imaging.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_imaging.c b/src/_imaging.c index 808112d57bb..7fee411149c 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -3172,8 +3172,8 @@ _draw_lines(ImagingDrawObject *self, PyObject *args) { PyObject *data; int ink; - int width = 0; - if (!PyArg_ParseTuple(args, "Oi|i", &data, &ink, &width)) { + int width; + if (!PyArg_ParseTuple(args, "Oii", &data, &ink, &width)) { return NULL; }