Repository navigation
Fix converting I and I;16 images with transparency to LA or RGBA - #10338
Merged
radarhere merged 4 commits intoOct 31, 2026
Merged
Conversation
radarhere
force-pushed
the
fix/16bit-grayscale-transparency
branch
from
October 31, 2026 08:12
5a23c9d to
4340a24
Compare
radarhere
force-pushed
the
fix/16bit-grayscale-transparency
branch
from
October 31, 2026 08:20
4340a24 to
2750223
Compare
radarhere
enabled auto-merge (squash)
October 31, 2026 08:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Refs #10330 (grayscale portion).
Converting an
I;16image with pixels[0x1234, 0x0034]and transparency key0x1234currently produces alpha[255, 0]instead of[0, 255]. The integer samples are clipped to 8 bits before matching, and the transparency key is truncated to its low byte.Iimages have the same problem, including false matches between negative values and zero or between distinct values clipped to 255.This change matches
IandI;16transparency against the original source samples and only changes the matching pixels' alpha. It preserves the existing color clipping and the conversion paths for other modes. Tests cover low-byte collisions, clipped values, two image rows, signed 32-bit boundaries, and a real 16-bit grayscale PNG round trip to both LA and RGBA. A release note is included.The 16-bit RGB case in #10330 remains unresolved: decoding has already discarded the low bytes, so simply shifting the transparency key would also match other source colors with the same high bytes. This PR does not close the whole issue.
Validation on Linux x86_64 / Python 3.14.7, with freshly built native extensions:
selftest.py: 59 passed.pytest Tests/ -n 4: 5,751 passed, 92 skipped, 3 expected failures.prek run --all-filesand the manual Pyroma hook: passed.tox -e mypy: passed (303 source files).Windows and macOS have not been tested locally. The full-suite skips include unavailable Ghostscript, some missing test images, and platform-specific cases.
AI disclosure: this contribution was developed, tested, and reviewed with OpenAI Codex. The account owner has not manually reviewed the code.