Nodes/SaltAI-Open-Resources/Mask with Alpha (Transparency)
ComfyUI Node

Mask with Alpha (Transparency)

Turn a MASK into real transparency

By get-salt-AI·Created 2 years ago·Updated 2 years ago· 84
Mask with Alpha (Transparency)
  • image
  • mask
  • rgba_image
threshold0.50
invert_maskfalse

ComfyUI's native IMAGE type doesn't carry an alpha channel - everything downstream of a normal generation is opaque RGB. So the moment you actually need transparency (a cutout you're going to composite somewhere, a PNG you want to drop straight onto a website background, a sticker), you need a node that bolts a MASK onto an image as its alpha channel. That's the entire job of SaltRGBAFromMask.

What it does

You feed it an image and a mask that's the same shape. Wherever the mask is bright, the pixel stays opaque; wherever it's dark, the pixel becomes transparent. There's a threshold (0–1, default 0.5) that decides the cutoff between "keep" and "drop," and an invert_mask toggle for when your mask is backwards relative to what you want kept - which happens constantly, since half the segmentation tools in ComfyUI mask the background and the other half mask the subject, and you never remember which is which until you look at the output.

Under the hood this is straightforward: it reads mask values, decides opacity against the threshold, and writes that into a fourth channel alongside the RGB. The single output, rgba_image, is what you send to a save node - ComfyUI's SaveImage respects an alpha channel when it's present, so a PNG saved from this node's output is genuinely transparent, not just "black background."

Where it fits in a real workflow

The obvious pairing is right after a segmentation step. Generate a subject, run something like SaltCLIPSegMasking (also in this pack) or any other mask-producing node to isolate it, then feed image + mask into SaltRGBAFromMask to get a clean cutout PNG. If the mask you're handed is soft and blobby - CLIPSeg's masks especially tend to be a little coarse at the edges - running it through this pack's SaltMaskThresholdRegion or SaltMaskSmoothRegion first, then into this node, gets you a cleaner edge than relying on the single threshold slider alone.

Installing it

Easiest path: ComfyUI Manager, search SaltAI-Open-Resources (or just "Salt AI"), install, restart. Manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/get-salt-AI/SaltAI

Restart ComfyUI. The pack's own README is thin - no special dependency list, no model downloads for this specific node. It's pure image math, so if the node loads at all (check your console for import errors on startup, the usual first move when a custom node pack goes missing from the menu), it'll run.

Where people get tripped up

The most common surprise is a fully-opaque or fully-transparent output, and it's almost always invert_mask set wrong for the mask you actually have - flip it and check again before you assume the node is broken. The second is downstream: if you paste the RGBA output into a workflow step that only handles RGB (most sampling and preprocessing nodes do), the alpha channel gets silently dropped or the node errors on channel count. Keep this node as close to the end of your graph as you can - right before the save - rather than trying to carry transparency through the middle of a pipeline. And if your edges look jagged rather than soft, that's the binary nature of a single threshold cutting a graded mask into a hard line; feather the mask upstream if you want a soft edge in the alpha channel, because this node itself doesn't blur anything for you.

CategorySALT/Image/Composite

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
maskMASK
thresholdFLOAT0.500–1
invert_maskBOOLEANfalse

Outputs (1)

NameTypeDescription
rgba_imageIMAGE