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

Do not down-convert if image is LA when showing with PNG format #3869

Merged
merged 3 commits into from Jun 19, 2019

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented May 25, 2019

Resolves #3868. ImageShow converts images to their base mode, unless they are 1 or RGBA. The issue reports that LA images lose their transparency - this is because the base mode is L. This PR resolves the issue by adding an exception for LA, adding to the existing exceptions for 1 and RGBA - although only if the output image format is PNG, since BMP cannot save in LA.

Unrelated to that problem, but around the same code, ImageShow has a condition to test for 'I;16' modes, stating that L is to be used instead of the base mode in those cases. However, Image.getmodebase("I;16") is L, so there is no difference. I have added a commit to add more mode descriptors to cover all I;16 modes, so that the ImageShow condition can be removed.

In doing that, I did find that ImageMode was listing the bands for the I;16 modes as a string, rather than as a tuple. When adding testing code to Tests/test_image_mode.py, it became apparent that this was inconsistent with other modes, so I have also fixed that.

@hugovk hugovk merged commit f338eae into python-pillow:master Jun 19, 2019
@radarhere radarhere deleted the imageshow branch June 19, 2019 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image.show() on image with mode LA does not show transparency
2 participants