Skip to content

Polygons aren't drawn the same #6908

@vinh-00

Description

@vinh-00

Hi,
I'm currently trying to migrate py2 to py3, from Pillow 6.2.1 to 9.3.0
I'm noticing some strange behaviors in the draw polygon functions, where my inputs are the same, but the outputs are slightly different.
Heres a test case below, to run on py2.7 remove the width arg.

from PIL import Image, ImageDraw
import numpy as np

def pil_test():

  poly = [(402,  52),(402,  52),(406,  54),(405,  55)]

  img = Image.new('I', (500, 500))
  draw = ImageDraw.Draw(img, mode='I')
  draw.polygon(poly, fill=100, width=0) 
  ## py2 - draw.polygon(poly, fill=100)
  
  iarr = np.array(img)
  print(iarr[52,403])

Pillow 6.2.1 output >> 0
Pillow 9.3.0 output >> 100

I would like to know if theres a workaround for this? or why is this happening?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions