Skip to content

Converting this 16-bit grayscale image to 'L' mode destroys it #3011

@ExplodingCabbage

Description

@ExplodingCabbage

Here is a 16-bit grayscale image:

test

It clearly contains a gradient of grays.

If I open it with Pillow, convert it to 8-bit grayscale, and save it, like so...

>>> from PIL import Image
>>> test_img = Image.open('test.png')
>>> test_img.mode
'I'
>>> test_img.convert('L').save('out.png')

... then I get this, which is mostly completely white:

out

This conversion should work; according to http://pillow.readthedocs.io/en/4.2.x/handbook/tutorial.html#converting-between-modes

The library supports transformations between each supported mode and the “L” and “RGB” modes.

and according to http://pillow.readthedocs.io/en/latest/handbook/concepts.html#modes, I is a supported mode.

Notably, I don't see this same problem if I start by loading an 8-bit RGB image from a JPG and then do .convert('I').convert('L'), so it's not simply the case that I->L conversion is broken in general. I'm not what specifically leads to the breakage in this case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions