Add Alpha Channel
Turn any mask into real transparency
- images
- mask
- rgba_images
The honest truth about ComfyUI is that a ton of "transparent" output isn't. Most node packs output plain RGB, and the alpha channel you carefully produced in a segmentation step gets silently dropped somewhere downstream. Add Alpha Channel is the node that actually makes the transparency real: it takes your image batch and your mask batch and fuses them into a proper 4-channel RGBA batch.
It's the middle step of this pack's video-to-transparent-PNG pipeline (Combine Video And Mask calls it internally), but it works just as well on stills. You cut a subject out of a photo with BiRefNet, feed the mask here, and get a genuine cutout.
How it works
The mask's first channel becomes the alpha: white = opaque, black = transparent, with anything in between becoming fractional transparency. If you feed a 3-channel RGB mask, it averages the channels down to one. Then it concatenates that alpha onto your RGB image, giving you a [B, H, W, 4] tensor.
Inputs
- images - the RGB batch you want to make transparent.
- mask - the alpha source. Same resolution and same batch size as the images; the node raises a clear error if the batch counts don't match.
- invert_mask - flips white↔black. Turn this on when your mask is inverted (background marked white instead of your subject).
- multiply_rgb - premultiplied alpha. It scales the RGB channels by alpha so edges fade toward black instead of holding their raw color. That's what you want if you're compositing against arbitrary backgrounds and hate fringes; it's what you don't want if you need the original edge colors for further processing. Default off, and off is a fine place to stay until a specific composite looks wrong.
Outputs
One output: rgba_images, a 4-channel IMAGE you can pipe into the pack's Save Images With Alpha, into any alpha-aware preview, or into a compositing chain.
Install
The standard pack install - Manager (search "ComfyUI-AutoFlow") or:
cd ComfyUI/custom_nodes
git clone https://github.com/ZXL-Xinram/ComfyUI-AutoFlow
then restart. No models, no requirements.txt; it only needs torch and numpy, which every ComfyUI already has.
Where people get burned
- Batch size mismatch. If your images batch has 5 frames and the mask batch has 4, you get an error - and you should, because there's no sensible way to pair them. Keep the counts aligned.
- Resolution mismatch. The node does not resize. A mask at a different resolution than the image gives you a silent channel-shape error at the
torch.cat. Resize your mask to match first. - Downstream alpha drop. The RGBA tensor is only as good as what you feed it into. A stock
Save Imagewrites JPEG/RGB and will flatten your transparency. Use this node's siblingAutoFlowSaveImagesWithAlphaif the goal is PNG files.
It's a small, single-purpose node in a young pack, but it does exactly one job correctly - and in the alpha pipeline, that's the job most other nodes quietly skip.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| mask | IMAGE | — | |
| invert_mask | BOOLEAN | false | — |
| multiply_rgb | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| rgba_images | IMAGE | — |