Skip to content

Silent truncation when converting I to RGBA #4044

Description

@anntzer

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.

Activity

  1. changed the title [-]silent truncation when converting mode-I to mode-RGBA[/-] [+]Silent truncation when converting I to RGBA[/+] on Sep 4, 2019
  2. radarhere commented on Sep 5, 2019

    @radarhere
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions