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

Image.Open() and 16bit gray images - int32 output #3041

Closed
lschaupp opened this issue Mar 14, 2018 · 4 comments
Closed

Image.Open() and 16bit gray images - int32 output #3041

lschaupp opened this issue Mar 14, 2018 · 4 comments

Comments

@lschaupp
Copy link

If you use Image.Open("test.png") on a uint16 png depth image
-> Pillow opens is with the mode "I" which is int32.
I'm wondering if this behaviour is intentional?
I guess there is no information loss involved - but why would you do this conversion to int32 instead
of the uint16?

Thanks!

@wiredfool
Copy link
Member

There's better support for image operations on int32 images than int16, especially for signed 16 bit images.

@anntzer
Copy link
Contributor

anntzer commented Sep 4, 2019

Is there any change this issue can be revisited? AFAICT Pillow's TIFF and JPEG handlers, for example, will happily open 16-bit data without upcasting, so I don't see why the PNG handler can't do the same.

anntzer added a commit to anntzer/matplotlib that referenced this issue Sep 4, 2019
The version check in _has_pil (pillow>=3.4) was dropped as the oldest
Pillow that supports Py3.6 (the oldest Python supported by Matplotlib)
is 4.0 anyways.

- PIL returns uint16 images as int32
  (python-pillow/Pillow#3041); we could adopt
  imageio's dtype correcting code if desired.
anntzer added a commit to anntzer/matplotlib that referenced this issue Sep 4, 2019
The version check in _has_pil (pillow>=3.4) was dropped as the oldest
Pillow that supports Py3.6 (the oldest Python supported by Matplotlib)
is 4.0 anyways.

- PIL returns uint16 images as int32
  (python-pillow/Pillow#3041); we could adopt
  imageio's dtype correcting code if desired.
@radarhere
Copy link
Member

This has been revisited in the form of #3796

@radarhere
Copy link
Member

I've created PR #7849 to address this.

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

5 participants