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

Silent truncation when converting I to RGBA #4044

Closed
anntzer opened this issue Sep 4, 2019 · 1 comment
Closed

Silent truncation when converting I to RGBA #4044

anntzer opened this issue Sep 4, 2019 · 1 comment

Comments

@anntzer
Copy link
Contributor

anntzer commented Sep 4, 2019

What did you do?

I converted an I-mode PNG with values >255 to RGBA.

What did you expect to happen?

Conversion without truncation (converting to the lower available bit depth in RGBA mode), or at least a warning about truncation.

What actually happened?

Values were silently truncated to 255

What are your OS, Python and Pillow versions?

  • OS: arch linux
  • Python: 3.7
  • Pillow: 6.1

The attached example file comes from http://www.schaik.com/pngsuite/pngsuite_bas_png.html.

basn0g16

import PIL, numpy as np
np.asarray(PIL.Image.open("basn0g16.png").convert("RGBA"))

=> nearly all values (except the top right corner, which has value zero) were truncated to 255.

I appreciate that resampling may be too complex to be automatically performed, but at least truncation should not be silent.

@radarhere radarhere changed the title silent truncation when converting mode-I to mode-RGBA Silent truncation when converting I to RGBA Sep 4, 2019
@radarhere
Copy link
Member

I'm going to say this is part of #3159.

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

No branches or pull requests

2 participants