ComfyUI Node

Outline Alpha Snap

An outline that hugs your cutout, not the rectangle around it

By dennisvink·Created 7 months ago·Updated 7 months ago· 0
Outline Alpha Snap
  • image
  • IMAGE
width1
color#222222

You cut a subject out with BiRefNet or rembg, and now you want the sticker look: a white (or any-color) border that traces the subject's actual edge. Drop that transparent PNG straight onto a background and you get the opposite of a sticker - a hard cutout with no boundary, and often a grey fringe where the background-remover's alpha fades to nothing. Outline Alpha Snap is the fix, and it does all of it in one pass: cleans the alpha, drops stray specks, and draws an outside-only outline around the opaque region. It's a small single-node pack, but it's the kind of node that ends up in every overlay, sticker, and icon workflow once you've used it once.

What it actually does

Read the source and the "snap" in the name makes sense. It's three steps:

  1. Snap the edge. Any semi-transparent pixel that touches a solid pixel (alpha ≥ 200) gets dropped to empty. That's the fringe-cleaner - it deletes the fuzzy halo that makes a cutout look bad against any background that isn't grey.
  2. Kill islands. Connected components are found, and everything except the largest one is removed. The dust specks and stray flecks that survive background removal disappear.
  3. Draw the outline. The cleaned mask is dilated by your width and the original subtracted, which gives you a ring that exists only outside the subject - then it's colored with your hex and composited underneath the image. The subject stays crisp on top; the outline never eats into it.

The inputs that matter

There are only three, and you'll touch two of them.

  • image (IMAGE) - feed it your cutout. Wire from a background-removal node, a transparent generation, or a loaded PNG.
  • width (INT, 0–256, default 1) - outline thickness in pixels. Set to 0 and the node still runs steps 1 and 2: a free edge-clean + island-removal pass, no outline.
  • color (STRING, default #222222) - hex only, and this is the neat part: it accepts #RRGGBBAA. You can give your outline its own alpha, so a semi-transparent white border on a sticker is one field away.

The single output is IMAGE, so it slots straight into Preview, Save, or a composite node for dropping the subject onto your background.

Installing it

Either grab it in ComfyUI Manager (search "Outline Alpha Snap"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/dennisvink/comfyui-outline

Then restart ComfyUI. There's no requirements.txt, no model download, nothing to pip install - the whole pack is one file using only numpy, torch, and Pillow, which ComfyUI already ships. It's as close to zero-friction as a custom node gets.

Where people get burned

  • RGB input = the whole frame is opaque. This node reads the alpha channel. Feed it a flat RGB image and it treats everything as solid, so your outline traces the image's outer edges. Always feed it an RGBA cutout.
  • Largest component only. Two characters in one PNG and you keep just the bigger one. Split the batch or process them separately if you need everything.
  • The snap is aggressive. Hair wisps that are semi-transparent and touch solid pixels get flattened. It's great for cartoonish cutouts and brutal for flyaway hair - expect crunchy edges there.
  • Colors must be hex. color: "red" raises a ValueError. Use #FF0000.
  • Keep it in the pipeline. A lot of nodes silently drop alpha on the way to the save node (the KB calls this out for LayerDiffusion workflows too). Check your PNG saved with the transparency you expect.

It's a one-trick pack, but it's a good trick, and it'll earn a permanent spot in any workflow that turns cutouts into stickers or overlays.

CategoryImage/Outline

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
widthINT10–256
colorSTRING#222222

Outputs (1)

NameTypeDescription
IMAGEIMAGE