-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
What did you do?
I drew a polygon on an image (16 bits grayscale)
What did you expect to happen?
The polygon should have been created at the specified coordinates
What actually happened?
The polygon was
What are your OS, Python and Pillow versions?
- OS: MacOS Ventura 13.2.1
- Python: 3.10
- Pillow: 10.3.0
Please paste here the output of running:
python3 -m PIL --report
---------------------------------------------------------------------
Pillow 10.3.0
Python 3.10.11 (main, Apr 7 2023, 07:24:53) [Clang 14.0.0 (clang-1400.0.29.202)]
--------------------------------------------------------------------
Python executable is /Users/antoine/Envs/jupyter/bin/python3
Environment Python files loaded from /Users/antoine/Envs/jupyter
System Python files loaded from /opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10
--------------------------------------------------------------------
Python Pillow modules loaded from /Users/antoine/Envs/jupyter/lib/python3.10/site-packages/PIL
Binary Pillow modules loaded from /Users/antoine/Envs/jupyter/lib/python3.10/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 10.3.0
*** TKINTER support not installed
--- FREETYPE2 support ok, loaded 2.13.2
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.3.2
--- WEBP Transparency support ok
--- WEBPMUX support ok
--- WEBP Animation support ok
--- JPEG support ok, compiled for libjpeg-turbo 3.0.2
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.2
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1
--- LIBTIFF support ok, loaded 4.6.0
--- RAQM (Bidirectional Text) support ok, loaded 0.10.1, fribidi 1.0.13, harfbuzz 8.4.0
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------
When trying to draw a polygon on a 16 bits grayscale image, everything works fine with version 10.2.0 but the polygon is misplaced and its outline color is ignored with version 10.3.0.
Note that both these issues are fixed in 10.3.0 if a fill color is specified as well
| 10.2.0 with only outline | 10.3.0 with only outline | 10.3.0 with both outline and fill |
|---|---|---|
![]() |
![]() |
![]() |
from PIL import Image, ImageDraw
IMAGE_PATH = "./image.png"
WHITE = 65536
COORDINATES = [(1284.0, 1852.0), (1485.0, 1940.0), (1422.0, 2053.0), (1233.0, 1965.0)]
if __name__ == '__main__':
image = Image.open(IMAGE_PATH)
draw = ImageDraw.Draw(image)
# This example works in 10.2.0 but not in 10.3.0
draw.polygon(COORDINATES, outline=WHITE, width=15)
# This example works in both 10.2.0 and 10.3.0
# draw.polygon(COORDINATES, fill=WHITE, outline=WHITE, width=15)
image.save('results.png')
image.close()Metadata
Metadata
Assignees
Labels
No labels



