Nodes/ComfyUI-CorridorKeyWrapper/CorridorKey Composite
ComfyUI Node

CorridorKey Composite

Why your keyed cutout still has a dark edge (and how this node fixes it)

By pixelworldai·Created 5 months ago·Updated 3 months ago· 2
CorridorKey Composite
  • foreground
  • alpha
  • background
  • composite
fg_is_linearfalse

You've keyed a subject, dropped it on a new background with the bog-standard composite node, and the edges are wrong - dark halos, colored fringes, a look that says "this was cut out." It's not your key. It's your math. Most default composite paths blend two gamma-encoded (sRGB) images directly, which is like averaging two numbers after squaring them: the arithmetic happens in the wrong space. CorridorKey Composite exists to do the composite the way compositing software has done it for decades - convert everything to linear light, blend, convert back.

The node takes a keyed foreground, an alpha mask, and a background, and returns a single clean composite image. It's the last step in the CorridorKey workflow: Load CorridorKey Model → Chroma Key Prepass → CorridorKey Greenscreen → CorridorKey Composite over your new background. It's also the part people skip, and it's the difference between "looks keyed" and "looks composited."

How it works

Under the hood it's short and honest. The foreground (unless you say it's already linear) and the background both get converted to linear RGB. Then it does a straight-over composite - composite_straight(fg, bg, alpha) - in that linear space, converts the result back to sRGB, and clamps. It also resizes the background to match the foreground with Lanczos4 if the dimensions differ, which saves you a Resize step and means you can drop in a background of any size.

Inputs and outputs

Three required inputs:

  • foreground (IMAGE) - your keyed subject. The CorridorKey Greenscreen foreground output is already un-premultiplied straight sRGB, which is exactly what this node expects. Don't feed it a premultiplied image.
  • alpha (MASK) - the matte. That's the alpha output from CorridorKey Greenscreen, or any mask you trust.
  • background (IMAGE) - anything: a generated scene, a photo, a frame from a video.

One optional:

  • fg_is_linear (false): set true only if your foreground is already in linear color space (an EXR path). For anything that came out of the Greenscreen node, leave it false.

The single output is composite (IMAGE), wired to Preview Image or Save Image.

The color-space trap

Everything about this node is really about one idea: sRGB pixels are gamma-encoded, and compositing math wants linear values. If you skip it and use a plain alpha-over composite, the semi-transparent edge pixels - the ones CorridorKey worked so hard to reconstruct - get blended with the wrong coefficients, and you see exactly the halo you thought the neural keyer would eliminate. Use this node, or anything else that does linear-light blending. It's the same reason the Greenscreen node has input_is_linear on its plate input: the whole pipeline lives in linear space and only converts at the edges.

When you don't need it

If you only want to eyeball the key, the Greenscreen node's comp_preview (checkerboard composite) is free - no background needed. CorridorKey Composite is for the real result over an actual background. And if you're compositing video, note this node keys one image at a time: for long footage you'll either loop it over your frames or hand the RGBA frames to a proper compositing tool. It also only composites over a flat background image - it won't do motion-tracked perspective or reflections. For that you're out of this pack's scope and into a real compositor.

Install

Same pack as the rest of the family - ComfyUI Manager, search ComfyUI-CorridorKey, or clone manually:

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

No extra models - it reuses the CorridorKey engine the loader pulls in, and the ~300MB checkpoint downloads to ComfyUI/models/corridorkey/ on first use. If the composite looks washed out or too bright, the usual culprit is a foreground that's already linear being told it's sRGB (or vice versa) - flip fg_is_linear and compare.

CategoryCorridorKey

Inputs (4)

NameTypeDefaultDescription
foregroundIMAGE
alphaMASK
backgroundIMAGE
fg_is_linearoptBOOLEANfalseSet True if the foreground is already in linear color space.

Outputs (1)

NameTypeDescription
compositeIMAGE