Nodes/ComfyUI-ImageCompositionCy/Combine Image Alpha 🔀
ComfyUI Node

Combine Image Alpha 🔀

Turning any mask into real transparency

By CY-CHENYUE·Created about a year ago·Updated about a year ago· 12
Combine Image Alpha 🔀
  • image
  • mask
  • image

ComfyUI's core LoadImage is awkward with transparency: it hands you the alpha as a MASK and the pixels as an RGB IMAGE, split apart. Combine Image Alpha 🔀 is the glue. It takes an RGB image and any mask and merges them into a single RGBA image - the format the Image Compositor (same pack) actually wants, and the format any real compositing step expects. You reach for it whenever the transparency already exists somewhere as a mask - a BiRefNet cutout, a SAM selection, an inpainted region, a mask you generated procedurally - and you want it as genuine, composable alpha rather than a mask you have to keep carrying alongside the pixels.

How it works

Simple node, but one twist is worth understanding because it will bite you. It takes the RGB image and the mask, resizes the mask to match the image (nearest-neighbor, so no weird interpolated fuzz), and computes alpha = 1 − mask, concatenating that as the fourth channel. It's also flagged as an output node, so it writes a temp preview PNG you can eyeball right in the node.

The twist: which side of the mask is "on"

ComfyUI's mask convention is white = active. Core LoadImage's mask output is literally the image's alpha channel - white where the image is opaque. This node inverts that: it computes alpha = 1 − mask, so a white mask becomes transparent and black becomes opaque. The pack's own README example shows LoadImage → [MASK] → Combine Image Alpha, which on a transparent PNG hands you a backwards result. So the #1 thing people get bitten by here: if your cutout comes out inverted, run the mask through an Invert Mask node before this one (or just feed it the opposite way round). It's baked into the source, not folklore, so it'll keep biting until the author flips it.

Inputs and outputs

Nothing to configure. image (IMAGE) and mask (MASK) go in; one image (IMAGE, RGBA) comes out. That's the whole node.

The typical flow:

LoadImage → [MASK] → Invert Mask → Combine Image Alpha → Image Compositor
      └──→ [IMAGE] ────────────────────────→┘

Or straight from a background-removal node's mask output. Either way it turns "a mask someone gave you" into "a layer with real transparency."

Install

cd ComfyUI/custom_nodes
git clone https://github.com/CY-CHENYUE/ComfyUI-ImageCompositionCy.git
cd ComfyUI-ImageCompositionCy
pip install -r requirements.txt

Then restart ComfyUI, or use ComfyUI Manager and search "ImageCompositionCy". No models, no downloads beyond the usual - requirements.txt is pillow, numpy and torch, all already present in a stock ComfyUI.

CategoryImageCompositionCy

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
maskMASK

Outputs (1)

NameTypeDescription
imageIMAGE