Honor RGBA channel count in Pillow resize goldens - #30
Merged
Merged
Conversation
Golden loading mapped every non-L mode to 3 channels, so regenerated RGBA cases from eval/gen-pillow-goldens.py failed length checks and never exercised 4-channel pillowResize. The browser CF path always resizes getImageData pixels. Prefer the stored channels field, map RGBA to 4, and add a compact RGBA golden to the committed subset. Co-authored-by: felirami <felirami@users.noreply.github.com>
Co-authored-by: felirami <felirami@users.noreply.github.com>
Pillow.Image.resize on RGBA premultiplies alpha, so random-alpha goldens cannot match the independent-channel browser CF path. Resize each RGBA band with BICUBIC and store a compact 4-channel golden in the committed subset. Co-authored-by: felirami <felirami@users.noreply.github.com>
felirami
marked this pull request as ready for review
August 15, 2026 22:22
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.
Summary
The Pillow golden loader treated every non-
Lmode as 3 channels. Regenerating witheval/gen-pillow-goldens.pywritesprod_down_rgbaasmode: RGBAandchannels: 4, so the length check failed (3145728vs2359296) and 4-channelpillowResizewas never byte-checked. The browser CF path always resizesgetImageDataRGBA pixels.A second issue showed up after the loader fix:
Image.resizeon RGBA converts to premultipliedRGBafirst, so random-alpha goldens cannot match independent-channelpillowResize. The generator now resizes each RGBA band with BICUBIC, which is the extension contract.Changes
goldenChannels()prefers the storedchannelsfield and mapsRGBAto 4. Older committed RGB/L entries withoutchannelsstill load frommode.noise()cases do not shift.compact_rgba(160x120 to 147x110, Pillow 12.3.0).Evidence
Reproduced against a regenerated
prod_down_rgbagolden before the fix: input length1024*768*4 = 3145728, loader expected1024*768*3 = 2359296.After the fix:
tests/pixel-resize.test.mjs19/19 pass, includingcompact_rgbaPIXEL_RESIZE_GOLDENSon the full 21-case regen (Pillow 12.3.0): 35/35 pass, includingprod_down_rgba(1024x768x4 to 587x440)npm test: 217/217 passPublic fixtures are directional only and are not a claim about Kenny's private held-out set.