You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Coords allows Sequence[Sequence], so it should support both tuple[tuple] and list[list] but currently it doesn't seem to be the case with ImageDraw.line - it fails with list[list] at runtime though there are no typing errors.
See example below.
fromPILimportImage, ImageDrawimportnumpyasnpimg_size= (200, 200)
scale=1.0img=Image.new("RGB", img_size, "white")
draw=ImageDraw.Draw(img)
verts=np.array(
[
[[22.0, 105.0], [114.0, 105.0]],
[[22.0, 105.0], [22.0, 23.0]],
[[114.0, 105.0], [114.0, 113.0]],
[[114.0, 113.0], [14.0, 113.0]],
[[14.0, 113.0], [14.0, 15.0]],
[[14.0, 15.0], [114.0, 15.0]],
[[114.0, 15.0], [114.0, 23.0]],
[[114.0, 23.0], [22.0, 23.0]],
]
)
forverts_inverts:
lst: list[list[float]]
lst=verts_.tolist()
# No typing errors but fails at runtime.# Traceback (most recent call last):# File "second_test.py", line 28, in <module># draw.line(verts_.tolist(), fill="black", width=2)# File "\Lib\site-packages\PIL\ImageDraw.py", line 249, in line# self.draw.draw_lines(xy, ink, width)# ValueError: incorrect coordinate type# draw.line(lst, fill="black", width=2)# Works fine.tple=tuple(tuple(i) foriinverts_)
draw.line(tple, fill="black", width=2)
# Show the imageimg.show()
The text was updated successfully, but these errors were encountered:
ImageDraw.line
is currently usingCoords
forxy
argument.Pillow/src/PIL/ImageDraw.py
Line 237 in c7ed097
Pillow/src/PIL/_typing.py
Line 40 in c7ed097
Coords
allowsSequence[Sequence]
, so it should support bothtuple[tuple]
andlist[list]
but currently it doesn't seem to be the case withImageDraw.line
- it fails withlist[list]
at runtime though there are no typing errors.See example below.
The text was updated successfully, but these errors were encountered: