Skip to content

Use pen widths when drawing ImageDraw2 shape outlines - #10207

Merged
radarhere merged 5 commits into
python-pillow:mainfrom
xiehuanyi:fix/imagedraw2-pen-width-20261014
Oct 15, 2026
Merged

radarhere merged 5 commits into
python-pillow:mainfrom
xiehuanyi:fix/imagedraw2-pen-width-20261014

Conversation

@xiehuanyi

Copy link
Copy Markdown
Contributor

Fixes #10206.

ImageDraw2.Pen(width=4) draws a four-pixel line, but shape outlines still have width one. Forward the selected pen width for arc, chord, ellipse, pieslice, polygon and rectangle, while preserving explicit render(width=...) overrides. Document the width and add a release note.

Regression tests compare all seven drawing operations with ImageDraw, with the pen in either argument position, and check rectangle border pixels directly. Existing shared-fixture tests now request width one, matching their fixture; the new tests cover wider outlines.

Validation on a fresh build of main with Python 3.12.13: 13 regressions fail before the fix, with 16 controls passing. After the fix, ImageDraw2/ImageDraw suites pass (341 tests, one existing expected failure), source selftest passes (59 tests), and ImageDraw2 coverage exercises the changed line. Configured mypy passes across all 303 source files. All applicable project pre-commit hooks pass, including pinned Black 26.10.0, Ruff 0.16.10, Bandit and Sphinx lint; Black 26.3.1 and diff checks pass too.

Discovered through a code audit, with the reproducer, patch and tests prepared and verified using GPT-6.1 Sol.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 13:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@radarhere radarhere added the 🤖-assisted AI-assisted label Oct 14, 2026
@radarhere

radarhere commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

It appears that when #3094 added width support to the ImageDraw shapes, no one ever fully thought through how it applied to ImageDraw2.

I've remove the release note, as this is an obscure function as far as Pillow use goes.

Comment thread src/PIL/ImageDraw2.py Outdated
@radarhere
radarhere force-pushed the fix/imagedraw2-pen-width-20261014 branch from 726107a to 687d7e5 Compare October 15, 2026 02:28
@radarhere radarhere changed the title Honor pen widths when drawing ImageDraw2 shape outlines Use pen widths when drawing ImageDraw2 shape outlines Oct 15, 2026
@radarhere
radarhere enabled auto-merge (squash) October 15, 2026 02:49
@radarhere
radarhere merged commit b741022 into python-pillow:main Oct 15, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-assisted AI-assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImageDraw2 ignores Pen.width for shape outlines

3 participants