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

Open 16-bit grayscale PNGs as I;16 #7849

Merged
merged 1 commit into from Mar 2, 2024
Merged

Conversation

radarhere
Copy link
Member

Resolves #3796

#3041 originally asked why PNGs were opened in I mode rather than I;16, and the response was

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

Nevertheless, #3796 was opened, and has received various comments.

The one I find compelling is #3041 (comment)

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.

Looking through our test images, it is true that 12bit.cropped.tif is opened as I;16, 16bit.MM.cropped.tif is I;16B and 16bit.cropped.j2k is I;16. So some consistency would be good.

This PR changes PNG to open as I;16 rather than I.

@hugovk hugovk merged commit dec3ef6 into python-pillow:main Mar 2, 2024
59 checks passed
@radarhere radarhere deleted the png_i16 branch March 3, 2024 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PNG opens as I rather than I;16
2 participants