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

lint: Test and improve PNG transparency check (f-019) #746

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

gvtulder
Copy link
Contributor

@gvtulder gvtulder commented Sep 4, 2024

se lint doesn't recognize some types of PNG transparency. This adds small test images with different types of transparency/non-transparency, and some additional code to cover:

  • PNG image.mode == "LA": grayscale with an alpha channel. Similar to the RGBA that was already supported.
  • PNG image.mode == "P": a palette-based images, but with multiple transparency levels. This means that image.info["transparency"] is a bytes string with an 0-255 alpha level for every indexed color. The current version of has_transparency only expected one single transparent index.

The test includes some transparent and some non-transparent images, where some of the non-transparent images have an unused alpha channel.

PIL.Image details per image:

mode info[transparency] Transparent?
illustration-1.png L None No
illustration-2.png LA None Yes
illustration-3.png P b'\x00\x11"3DUfw\x88\x99\xaa\xbb\xcc\xdd\xee' Yes
illustration-4.png P 0 Yes
illustration-5.png RGBA None Yes
illustration-6.png RGBA None No
illustration-7.png RGB None No
illustration-8.png LA None No

@acabal acabal merged commit dfad53d into standardebooks:master Sep 4, 2024
1 check passed
@acabal
Copy link
Member

acabal commented Sep 4, 2024

Great, thanks!

@gvtulder gvtulder deleted the f-png-transparency branch September 23, 2024 22:13
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

Successfully merging this pull request may close these issues.

2 participants