Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageDraw.polygon produces the wrong image #8616

Open
SakuMyl opened this issue Dec 22, 2024 · 0 comments
Open

ImageDraw.polygon produces the wrong image #8616

SakuMyl opened this issue Dec 22, 2024 · 0 comments

Comments

@SakuMyl
Copy link

SakuMyl commented Dec 22, 2024

What did you do?

Drew a polygon with PIL's Image and ImageDraw modules

What did you expect to happen?

The Polygon should look consistent without holes in the middle

What actually happened?

There are holes and gaps.

What are your OS, Python and Pillow versions?

  • OS: Ubuntu 22.04.5 LTS
  • Python: Python 3.10.12
  • Pillow: 11.0.0
Pillow 11.0.0
Python 3.10.12 (main, Nov  6 2024, 20:22:13) [GCC 11.4.0]
--------------------------------------------------------------------
Python executable is /home/ghrunner/venv/bin/python3
Environment Python files loaded from /home/ghrunner/venv
System Python files loaded from /usr
--------------------------------------------------------------------
Python Pillow modules loaded from /home/ghrunner/venv/lib/python3.10/site-packages/PIL
Binary Pillow modules loaded from /home/ghrunner/venv/lib/python3.10/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 11.0.0
*** TKINTER support not installed
--- FREETYPE2 support ok, loaded 2.13.2
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.4.0
--- JPEG support ok, compiled for libjpeg-turbo 3.0.4
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.2
--- ZLIB (PNG/ZIP) support ok, loaded 1.2.11
--- LIBTIFF support ok, loaded 4.6.0
--- RAQM (Bidirectional Text) support ok, loaded 0.10.1, fribidi 1.0.8, harfbuzz 10.0.1
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok

Code to reproduce the issue along with the images:

from PIL import Image, ImageDraw
import matplotlib.pyplot as plt

shape = (35, 15)
pts = [(31, 12), (30, 12), (28, 11), (28, 10), (26, 7), (23, 7), (22, 8), (22, 13), (22, 13), (21, 13), (20, 14), (18, 14), (17, 13), (15, 13), (13, 11), (10, 11), (8, 13), (5, 13), (4, 12), (3, 12), (1, 10), (1, 8), (3, 5), (4, 6), (5, 6), (6, 7), (6, 8), (8, 10), (9, 10), (10, 10), (10, 4), (13, 0), (19, 0), (21, 2), (21, 3), (22, 4), (23, 3), (24, 3), (26, 6), (26, 7), (31, 12)]
img = Image.new("L", shape, 0)
draw = ImageDraw.Draw(img)
draw.polygon(pts, fill=255)
img.save('polygon.png')

x, y = zip(*pts)
plt.figure(figsize=shape)
plt.plot(x, y, marker='o', linestyle='-', color='blue', markersize=5, label='Points and Lines')

plt.scatter(x, y, color='red', zorder=5, label='Points')

plt.title("Visualization of Points with Connections")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.grid(True)
plt.legend()
plt.savefig('points.png')

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant