Join Image with Alpha
Turn a mask into a PNG's alpha channel in one node
- image
- alpha
- IMAGE
Every time you need a PNG with real transparency - a product cutout for a scene, a LayerDiffusion layer, a sticker you want to drop on any background - you run into ComfyUI's weird split personality around alpha. There are two ways transparency lives in this graph: as a MASK (a single channel where white means transparent) or as the fourth channel of an RGBA image. JoinImageWithAlpha is the bridge: it takes an image and a mask and glues them into one proper RGBA output.
Why does this matter? Because most of ComfyUI's nodes only look at the first three channels and quietly drop the fourth. Your carefully cut-out subject comes out of a background-removal node as RGB plus a mask, and if you just save it, you get an opaque block with your subject's old background baked back in. The reliable pattern is: keep the RGB and the mask as separate wires, do your edits, then use this node at the very end to reassemble the transparent PNG right before saving.
How it works. It inverts the mask into an alpha channel - a white (1) mask pixel becomes fully transparent, black becomes fully opaque - resizes the mask to match the image dimensions if they differ, and concatenates it on as the fourth channel. It only reads the image's RGB channels, so if you feed it an image that already has alpha, that old alpha is replaced rather than kept. Output is a single IMAGE, 4 channels, ready for any node that saves RGBA PNGs.
The inputs that matter. Just two: image and alpha, where alpha is a MASK - not an image, not a transparency slider. That's the whole node. The mask gets bilinear-resized to the image size, so a low-resolution mask comes back upscaled and slightly softened. That's usually a feature: it feathers the edge instead of giving you a 1-pixel hard cut. Don't expect a surgical alpha from a tiny mask.
Where people get burned. Polarity, first and foremost. ComfyUI's mask convention is the opposite of Photoshop's: white means transparent here. If your output PNG comes out fully invisible, or fully solid, your mask is inverted - flip it and rerun. Second: the alpha survives only if the node that saves the image actually writes it. Save Image handles RGBA fine for PNG, but some export and preview paths are RGB-only, and then your transparency vanishes exactly where you were trying to keep it. This is the "nodes silently drop the alpha channel" problem the background-removal docs warn about; keep the mask as a wire for as long as you can.
It ships with ComfyUI core and loads no model files - it's pure tensor plumbing, added to the core graph in August 2024 alongside its partner SplitImageWithAlpha. If you've never needed it, you haven't worked with transparency yet. If you have, it's the two-minute fix that makes the whole RGBA pipeline possible.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| alpha | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |