Repository navigation
fix(picture): compare PNG tRNS keys by their low byte - #2100
Merged
Merged
Conversation
shuuul
force-pushed
the
fix/png-trns-low-byte
branch
2 times, most recently
from
November 4, 2026 13:58
6f538a0 to
14a2a4a
Compare
Contributor
Author
Owner
ashhart
force-pushed
the
fix/png-trns-low-byte
branch
from
November 4, 2026 17:53
14a2a4a to
f7ac7b0
Compare
9 tasks done
Match Pillow RGB and grayscale transparency conversion while preserving mode 1 whole-key behavior. Five Pillow 12.3 fixtures cover 16-bit RGB and grayscale, 8-bit out-of-range keys and a 1-bit key of 256. Validation on upstream main f5bc3c5; these sources are unchanged at 45876f5, where only CHANGELOG.md differs: zig build (31 steps); zig build test test-golden (509/509 steps; 4664/4696 tests passed, 32 skipped; 322/335 parity, 13 known differences, 0 unexpected; 55/55 security). All commands held the shared machine lock.
ashhart
force-pushed
the
fix/png-trns-low-byte
branch
from
November 4, 2026 19:17
f7ac7b0 to
029d175
Compare
Owner
|
Thank you @shuuul. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
Owner
|
Thanks @shuuul! This is in TensorFold 1.2.3, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.3 |
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.
Fixes #2083.
What this changes
PNG
tRNSkeys for grayscale and RGB are compared with the decoded samples, which are the file's 8-bit values in the mode Pillow opens.Keys.ofkept the whole 16-bit key, so a 16-bit key of 257 left sample 1 opaque, and a key of 300 left sample 44 opaque. The comment above the code already says "with the 8-bit values of its mode".This masks the gray and RGB key components with
0xff, matching Pillow 12.3'sConvert.crgbT2a. The 1-bit grayscale rule is unchanged: key 256 still makes bit 1 transparent by its whole value.atc overlap --json:complete: false(pullFilesUnavailable,timeLimit); the one overlap found is PR Native Vulkan backend for Qwen3.5-2B (opt-in): engine and kernel-contract registration (stacked on #1526) #1544, one shared file,conflict: "clean"; no worktree overlaps.Fixtures and test
zig/tests/fixtures/picture/trns.jsonholds five PNGs generated with Pillow 12.3 and their expected RGBA bytes:png_rgb16_keypng_gray16_key_low_bytepng_gray8_key_past_255png_rgb8_key_past_255png_gray1_key_256picture_test.zigdecodes each case and compares the SHA-256 of the RGBA bytes. Withmain's whole-key comparison the test reports the four masking cases as mismatches andpng_gray1_key_256as a match; with this change all five match.zig/tests/fixtures/picture/edges.jsonalready carriedpng_rgb16_keyandpng_gray16_keycases, but their keys are 37/92/147 and 255, all below 256, so masking does not change them and they pass either way; the new fixture uses keys that distinguish the two rules.Checks on this head
python3 tools/zig/lean_check.py, on the base and on this head: 425 and 425 problems, 0 new.zig build test-picture-host: 25 passed, 4 skipped (the four require the pinned libwebp). The new test is one of the 25.png.zigreverted tomain's comparison, the same test fails on exactly the four masking cases and passespng_gray1_key_256; restored, it passes.zig build: 31/31 steps.zig build test test-golden: 509/509 steps; 4,664 of 4,696 tests passed, 32 skipped; server goldens 322/335 with 13 known differences and 0 unexpected; security 55/55.Receipt
Host-only change to the native picture decoder; no inference, checkpoint, kernel or backend path is reached.
45876f5f, Zig 0.17.0, aarch64 Linux, host only, no GPU.zig/src/core/picture/png.zigand its test on aarch64 Linux. Platform-specific decoder paths are unchanged.