Fixed joined corners for ImageDraw rounded_rectangle() odd dimensions #7151
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #7149
The issue has found that certain coordinates passed to
rounded_rectangle()
triggerValueError: y1 must be greater than or equal to y0
atPillow/src/PIL/ImageDraw.py
Lines 378 to 383 in 2a274a4
These lines are trying to draw a rectangle in between the rounded corners. In
the user isn't specifying any
corners
, so by default they are all on.corners[0]
is lowering the top of this middle rectangle from 0 to 4, andcorners[3]
is raising the bottom from 7 to 3... meaning the top is now lower than the bottom, resulting in the error. In more human terms, the code has concluded that there isn't any middle rectangle that needs to be drawn, because the two corners join. This is referred to earlier in ImageDraw asfull_y
.Pillow/src/PIL/ImageDraw.py
Lines 318 to 324 in 2a274a4
So this PR updates the detection of
full_x
andfull_y
to cover this scenario that has resulted from an odd height.