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

Is the ImageDraw.Draw.rectangle documentation wrong? #3597

Closed
ghost opened this issue Jan 19, 2019 · 4 comments
Closed

Is the ImageDraw.Draw.rectangle documentation wrong? #3597

ghost opened this issue Jan 19, 2019 · 4 comments

Comments

@ghost
Copy link

ghost commented Jan 19, 2019

What did you do?

I read the documentation on PIL.ImageDraw.Draw.rectangle, which states: The second point is just outside the drawn rectangle. (source: https://pillow.readthedocs.io/en/3.0.x/reference/ImageDraw.html )

Then, I tried out drawing a rectangle of size (0, 0, 200, 20)

What did you expect to happen?

A rectangle that starts at pixel 0 and ends before pixel 200, that is 0-199, with 200 pixels width, with 20 pixels height

What actually happened?

A 201x21 px rectangle, as if the ending point was just inside the rectangle (instead of outside as the docs say)

What are your OS, Python and Pillow versions?

  • OS: Ubuntu 18.04 (inside docker, host is fedora 29)
  • Python: 3.6.7
  • Pillow: 5.4.7 (PIL.PILLOW_VERSION)
# (don't have a minimal example right now)
@radarhere
Copy link
Member

radarhere commented Jan 19, 2019

I will note that there is no Pillow 5.4.7.

Here is code to demonstrate your situation -

from PIL import Image, ImageDraw
im = Image.new("RGB", (300, 300), "#fff")
d = ImageDraw.Draw(im)
d.rectangle((0, 0, 200, 20), "#000")
im.save("out.png")

@ghost
Copy link
Author

ghost commented Jan 19, 2019

@radarhere that's what PIL.PILLOW_VERSION was set to for some reason 🤷‍♀️ I don't know

@matkoniecz
Copy link

matkoniecz commented Jan 28, 2019

And even better example - there is no need to count pixels, just note that black line appeared + show function.

from PIL import Image, ImageDraw
im = Image.new("RGB", (300, 30), "#fff")
d = ImageDraw.Draw(im)
d.rectangle((10, 10, 290, 10), "#000")
im.save("out.png")
im.show()

out

matkoniecz added a commit to matkoniecz/quick-beautiful that referenced this issue Jan 28, 2019
@radarhere radarhere changed the title Is the ImageDraw.Draw.rectangle documentation wrong, or am I just not reading it right? Is the ImageDraw.Draw.rectangle documentation wrong? Feb 1, 2019
@radarhere
Copy link
Member

Feel free to comment if you think otherwise, but I'm closing this is as a duplicate of #1668.

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

No branches or pull requests

2 participants