Repository navigation
fix(nodes): read the real alpha channel in Mask from Alpha - #10173
Open
MohammadHijjawi97 wants to merge 2 commits into
Open
MohammadHijjawi97 wants to merge 2 commits into
MohammadHijjawi97 wants to merge 2 commits into
Conversation
Mask from Alpha took the image's last band, which for an image without alpha is the blue channel (RGB), the gray channel (L) or palette indices (P). Convert to RGBA first, so opaque images give a solid mask and palette transparency is honored.
JPPhoto
self-requested a review
November 9, 2026 20:07
JPPhoto
requested changes
Nov 9, 2026
JPPhoto
left a comment
Collaborator
There was a problem hiding this comment.
@MohammadHijjawi97 Thanks for the submission.
Findings/issues:
invokeai/app/invocations/image.py:244: For RGB/L/P inputs,tomasknow returns opaque pixels instead of the previous last-band values, but its decorator atimage.py:233remains version1.2.2. Saved workflows with that version appear current in webv2 (invokeai/frontend/webv2/src/features/workflow/core/document.ts:431), so users get no update warning as their masks change. A version bump is required when a node's functionality, inputs, or outputs change substantially; in this case, a minor version bump is acceptable to serve as an alert to users. This does not need an additional test.
The node now returns an opaque mask for images without an alpha channel instead of their last band, so saved workflows should be flagged as using an older version.
Contributor
Author
JPPhoto
requested changes
Nov 11, 2026
Collaborator
There was a problem hiding this comment.
@MohammadHijjawi97 One case that I think this needs to preserve original behavior for is input mode 'L' (not 'LA') images. The mask in that case should be treated as before rather than using the alpha channel; that was the original intent of the node, IIRC, and your changes break it. You can confirm this by looking at the workflow builders in invokeai/frontend/webv2.
This branch has not been deployed
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
Mask from Alpha took the image's last band as the mask. For an image without an alpha channel that is not alpha: it is the blue channel for RGB, the gray values for L, and palette indices for P (the saved "mask" is then even a P-mode image). The node now converts to RGBA and reads the A channel, so an opaque image gives a solid white mask and palette transparency is honored. RGBA/LA input is unchanged.
Before (RGB pixels red, green, dark blue): mask
[0, 0, 64]After: mask
[255, 255, 255]Related Issues / Discussions
None.
QA Instructions
uv run --no-sync pytest tests/app/invocations/test_image.py: 20 passed. Without the fix, the RGB case returns[0, 0, 64]and the palette case saves a P-mode image.uv run --no-sync pytest tests/app/invocations/test_image_manipulation_invocations.py tests/app/invocations/test_mask_bounding_box.py: passed.uv tool run ruff@0.11.2 check/format --checkon the changed files: clean.Review
The node's fields and version are unchanged.
Checklist
What's Newcopy (if doing a release after this PR)Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.