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.rectangle off by a factor of 2 for uint16 type images #3747

Closed
TAdeJong opened this issue Mar 25, 2019 · 0 comments · Fixed by #3899
Closed

ImageDraw.rectangle off by a factor of 2 for uint16 type images #3747

TAdeJong opened this issue Mar 25, 2019 · 0 comments · Fixed by #3899
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects

Comments

@TAdeJong
Copy link

TAdeJong commented Mar 25, 2019

What did you do?

Draw a rectangle of size 6*6 in a image with dtype np.uint16, per following code:

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

I = Image.fromarray(np.zeros((8,8), dtype=np.uint16))
d = ImageDraw.Draw(I)
d.rectangle([0,0,5,5], fill='white')
np.asarray(I)

What did you expect to happen?

An output similar to the case of a float image or a uint8 image, (taking into account #367 and #1668), with a square white triangle.

What actually happened?

The output is as follows:

array([[65535, 65535, 65535,     0,     0,     0,     0,     0],
       [65535, 65535, 65535,     0,     0,     0,     0,     0],
       [65535, 65535, 65535,     0,     0,     0,     0,     0],
       [65535, 65535, 65535,     0,     0,     0,     0,     0],
       [65535, 65535, 65535,     0,     0,     0,     0,     0],
       [65535, 65535, 65535,     0,     0,     0,     0,     0],
       [    0,     0,     0,     0,     0,     0,     0,     0],
       [    0,     0,     0,     0,     0,     0,     0,     0]],
      dtype=uint16)

So the rectangle is only half the width compared to the expected size. This only happens for uint16 images as far as I checked.

What are your OS, Python and Pillow versions?

  • OS: Windows 10
  • Python: Anaconda 3.6.8
  • Pillow: 5.4.1
@radarhere radarhere removed the NumPy label Apr 13, 2019
@aclark4life aclark4life added the Bug Any unexpected behavior, until confirmed feature. label May 11, 2019
@aclark4life aclark4life added this to Backlog in Pillow May 11, 2019
@aclark4life aclark4life moved this from Backlog to In progress in Pillow May 11, 2019
Pillow automation moved this from In progress to Closed Jun 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects
Pillow
  
Closed
Development

Successfully merging a pull request may close this issue.

3 participants