Repository navigation
Fix alpha of APNG frames blended with OP_OVER - #10582
Merged
Merged
Conversation
Frames using APNG_BLEND_OP_OVER were applied with Image.paste() and the frame's own alpha as mask, which also interpolates the alpha channel. Drawing a partially transparent pixel over an opaque canvas therefore made the canvas partially transparent (alpha 128 over alpha 255 gave 191). Use alpha compositing for RGBA and LA images instead.
radarhere
force-pushed
the
fix/apng-over-alpha
branch
from
November 22, 2026 12:06
f31cd74 to
349b273
Compare
radarhere
force-pushed
the
fix/apng-over-alpha
branch
from
November 22, 2026 12:10
349b273 to
77875f2
Compare
Member
|
For reference, https://wiki.mozilla.org/APNG_Specification
|
radarhere
enabled auto-merge (squash)
November 22, 2026 12:19
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.
Changes proposed in this pull request:
Blend.OP_OVERwere pasted with the frame's alpha as a mask, which also interpolated the alpha channel. Over an opaque area, alpha 128 read back as 191 (spec: 255). Over a transparent area,(0, 0, 255, 128)read back as(0, 0, 128, 64)(spec:(0, 0, 255, 128)). Now they are alpha composited withImage.core.alpha_composite. Other modes are unchanged.test_apng_blend_over_alphafor LA and RGBA.blend_op_over_near_transparent.png97 -> 255,mode_16bit.png191 -> 255 andmode_grayscale_alpha.png191 -> 255. The test suite these fixtures come from (philip.html5.org, cited in Add APNG support #4243) states they "should be solid green" / "should be solid grey".test_file_apng.pyfails on main (4 failed, 54 passed) and passes with the change (58 passed);test_file_png.py,test_imagesequence.pyandtest_file_webp_animated.pypass (150 passed, 1 skipped).The implementation were written with AI assistance.