Do not down-convert if image is LA when showing with PNG format #3869
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.