Image Alpha Join
Rebuild an RGBA image from RGB plus a separate mask
- image
- mask
- image
ComfyUI splits image data into two kinds of tensors: IMAGE (RGB or RGBA) and MASK (a separate grayscale layer). That split is convenient in the graph and awkward at the edges - every time you need to hand a real 4-channel RGBA image to a downstream consumer (an image-edit model, a save node, an API), you have to put the two back together. Image Alpha Join is the join: it combines an optional image with an optional mask into a single 4-channel output.
It's the kind of node you don't think about until you need it, and then you need it constantly. If you've ever stared at an error about "expected 4 channels, got 3," this is the fix.
How it works
Three cases, all handled:
- image only - RGB from the image, alpha filled fully white (opaque). Downstream gets a proper RGBA with no transparency surprises.
- mask only - a fully transparent image sized from the mask. Note the subtlety: it uses the mask's dimensions and ignores its values, producing an empty transparent canvas. That's a placeholder, deliberately.
- image + mask - RGB from the image, alpha from the mask. And here's the default that trips everyone up:
invert_maskis on by default, so the mask is inverted before it becomes alpha. The author's reasoning is that many workflows treat white as "remove / make transparent," so the inversion is what actually makes a white region transparent in the output.
Size mismatches are resolved by resizing the mask to the image with nearest-neighbor sampling, and batch counts on either side are cycled to match. If the image already has an alpha channel, it's ignored - the RGB is used and the mask (or full white) provides the alpha.
Inputs: image, mask, invert_mask. Output: image (always RGBA).
Install
Part of ComfyUI-1hewNodes:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
Restart ComfyUI. No models, no downloads.
Where it fits
- RGBA reconstruction - you split alpha out for processing (the pack's
Image Alpha Splitdoes that), process the RGB and the mask separately, then join them back for saving as a transparent PNG-style image. - Edit-model prep - several image-edit conditioning stacks expect 4-channel input; this is the bridge from your graph's separate image+mask wires.
- Placeholder plumbing - the mask-only transparent canvas keeps RGBA pipelines dimensionally consistent.
Common issues
- Transparency is backwards - it's
invert_mask=truedoing its job. White mask = transparent in the output. If your mask is already meant to be the literal alpha, setinvert_mask=false. - Original alpha vanished - an RGBA input gets its alpha dropped in favor of the mask/full-white path. That's documented behavior; if you want to keep the input's own alpha, don't route through here.
- Everything came out opaque - only
imageconnected means white alpha everywhere. Connect a mask if you wanted transparency.
One default to remember: invert_mask=true. Get that straight and the node behaves exactly like you'd expect - and most people's workflows end up keeping the default on.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| invert_mask | BOOLEAN | true | — |
| imageopt | IMAGE | — | |
| maskopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |