Nodes/Allor Plugin/AlphaChanelAddByMask
ComfyUI Node

AlphaChanelAddByMask

Turn any mask into a real alpha channel

By Nourepide·Created 3 years ago·Updated 2 years ago· 295
AlphaChanelAddByMask
  • images
  • mask
  • IMAGE
method

AlphaChanelAddByMask is where Allor's alpha family gets interesting: it takes an image and a MASK and bakes the mask into the image's alpha channel, producing a real RGBA image with transparency. If you've got a segmentation mask, an inpaint mask, or any selection that you want to become the transparency of the image itself, this is the node.

The inputs: images (IMAGE), mask (MASK), and a method dropdown with two options - default and invert. The naming is (again, one L - it's "Chanel" in this whole pack) beside the point; what matters is the polarity:

  • default - alpha is the inverse of the mask (1 − mask). Where the mask is white (1.0), the image becomes transparent; where it's black, opaque.
  • invert - alpha equals the mask directly. White mask → opaque, black mask → transparent.

In plain terms: invert keeps what the mask selects, default carves out everything except the mask. If your cutout comes out backwards - subject transparent, background opaque - flip this one dropdown and it fixes itself. The RGB channels pass through untouched either way.

Three behavior notes that will save you a confused session:

  • Mask and image must be the same resolution. A size mismatch raises a clear error telling you exactly what's off. Resize one side first.
  • Batch handling. If the mask has fewer frames than the images, the mask is broadcast across the batch, so one mask can drive every image.
  • The 64×64 special case. A 64×64 mask is treated as "no meaningful mask" and zeroed out - that's ComfyUI's default mask size for a disconnected input, so a dead MASK wire won't crash the node. In invert mode that zeroed mask makes the whole image transparent, which is the one gotcha that will actually bite you; it's a tell that the mask didn't actually connect.

Output is the RGBA IMAGE, ready for a PNG save or compositing.

Installing it

It's part of the Allor plugin:

cd ComfyUI/custom_nodes
git clone https://github.com/Nourepide/ComfyUI-Allor
cd ComfyUI-Allor
pip install -r requirements.txt

Restart ComfyUI, or search "Allor" in ComfyUI Manager. Pack-level notes: requirements.txt pulls in rembg and onnx for the segmentation nodes even though this node is pure tensor math, and Allor's repo was rebased to strip images from git history - auto-update failures are a known side effect, covered in the docs at nourepide.github.io/ComfyUI-Allor-Doc.

Real talk

This is the bridge between "I have a mask" and "I have a transparent image," and it's the node I'd reach for right after a background-removal or segmentation pass. The polarity dropdown is the only real trap, and it's a ten-second fix. Pair it with AlphaChanelAsMask (alpha → mask) and you can round-trip masks through alpha and back without ever leaving the graph.

Categoryimage/alpha

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE
maskMASK
methodCOMBO2 options: default, invert

Outputs (1)

NameTypeDescription
IMAGEIMAGE