Nodes/ComfyUI 1hewNodes/Image Alpha Join
ComfyUI Node

Image Alpha Join

Rebuild an RGBA image from RGB plus a separate mask

By 1hew·Created about a year ago·Updated 7 days ago· 33
Image Alpha Join
  • image
  • mask
  • image
invert_masktrue

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_mask is 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 Split does 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=true doing its job. White mask = transparent in the output. If your mask is already meant to be the literal alpha, set invert_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 image connected 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.

Category1hewNodes/image

Inputs (3)

NameTypeDefaultDescription
invert_maskBOOLEANtrue
imageoptIMAGE
maskoptMASK

Outputs (1)

NameTypeDescription
imageIMAGE