Nodes/Link Comfy Nodes/Replace Alpha
ComfyUI Node

Replace Alpha

Swap or inject transparency into a batch of frames

By Mister-Link·Created 9 months ago·Updated 24 days ago· 0
Replace Alpha
  • frames
  • alpha
  • mask
  • frames
  • alpha
color#FFFFFF

Two situations where this comes up in a rotoscoping or compositing pipeline: you've got a mask that's better than the alpha you're currently carrying (a fresh segmentation result, a cleaner matte from further downstream) and want to swap it in, or you've got frames that never had transparency at all and you need to inject it from a mask you built separately. Replace Alpha handles both - the pack's README describes it plainly as replacing or injecting alpha channels.

How it works

Four fields tell the story even without a written breakdown of the internals: frames is your image batch, alpha is the transparency currently associated with it, mask is the new mask driving the change, and color is a fill hex value. Put together, that reads as: the node replaces the frames' alpha using mask, and wherever that swap exposes new background - pixels that are no longer covered by the new alpha but weren't transparent before - it fills with color instead of leaving a black or undefined edge. That fill color matters more than it looks like it should: get it wrong and you end up with a visible fringe or halo around your subject once the new alpha is composited or keyed downstream.

The inputs and outputs that matter

  • frames (IMAGE) - the source batch.
  • alpha (MASK) - the frames' current alpha state.
  • mask (MASK) - the new mask that drives the replacement.
  • color (STRING, default #FFFFFF) - the fill color used where the swap exposes new content. Set this to match whatever your footage is headed toward next - a solid color that matches your intended background if this is final output, or a color you can key out cleanly (green, for instance) if you're planning to composite or key again downstream.

Outputs: frames and alpha - both come back updated, ready for a preview node (Preview Image (Alpha) in this same pack pairs naturally here) or a save/spritesheet step.

How to install it

Search "Link Comfy Nodes" in ComfyUI Manager and install from there. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/Mister-Link/link-comfy-nodes
pip install -r link-comfy-nodes/requirements.txt

Restart ComfyUI. No extra model downloads specific to this node.

Common issues & troubleshooting

color needs to be a valid hex string. The default is #FFFFFF; stick to that format (#RRGGBB) rather than a named color like "white" - this is a plain string field, not a color picker with validation, so a malformed value is likely to fail or produce an unexpected fill rather than silently correcting itself.

Shape mismatches between the three image/mask inputs. frames, alpha, and mask all need to line up frame-for-frame and pixel-for-pixel - the same batch-size and dimension gotcha that shows up across every masking node in this pack. Check all three come from sources with matching batch counts before wiring them in.

A visible fringe after compositing. If your subject has a halo once it's placed over a new background, that's almost always the color fill not matching where the frame is headed. Pick a fill color deliberately based on your next step, rather than leaving the default in place out of habit.

Preview before you commit. Because this node has no visual output of its own, wire its frames and alpha outputs into Preview Image (Alpha) before sending them further down the pipeline - that's the fastest way to catch a bad fill color or a botched replacement before it's baked into an export.

CategoryVideo/Masking

Inputs (4)

NameTypeDefaultDescription
framesIMAGE
alphaMASK
maskMASK
colorSTRING#FFFFFF

Outputs (2)

NameTypeDescription
framesIMAGE
alphaMASK