Nodes/Node - Size Matcher/Paste Cutout on Base Image
ComfyUI Node

Paste Cutout on Base Image

Paste a Cutout on Any Base Image Without Fighting the Sizes

By christian-byrne·Created 2 years ago·Updated 2 years ago· 5
Paste Cutout on Base Image
  • base_image
  • cutout
  • cutout_alpha
  • IMAGE
size_matching_method
invert_cutoutfalse

You got the subject out - BiRefNet, RMBG, a chroma key, whatever - and now you have the annoying second half of the job: actually sticking it onto a background. This is the node for that. "Paste Cutout on Base Image" (class Composite Alpha Layer) is the composite half of the size-match-compositing-nodes pack, and its whole pitch is that it does two things you'd otherwise chain by hand: it matches the cutout's size to the base image, then blends them, in one step.

It earns its keep in exactly the workflows the community actually runs: cut a subject out, then drop it on a generated background without the seam and the resize-chain mess. Think of it as the paste step that follows any of the background-removal models in ComfyUI's core - it handles the alpha and the geometry so you don't have to babysit either.

How it works

You feed it base_image, a cutout (your subject), and cutout_alpha (a MASK that says where the cutout is transparent). Pick a size_matching_method - the same seven options as the pack's size-matcher node, from cover_crop_center up to crop_larger_topleft - and optionally invert_cutout, and out comes a single composited IMAGE ready for a Save or Preview node.

The mechanism is straightforward: it recombines the cutout with its alpha, size-matches the base and cutout with your chosen method, then blends pixel-by-pixel (cutout * alpha + base * (1 - alpha)). No fancy ML, no diffusion - this is pure, fast compositing.

Two behaviors matter more than the blend itself:

Missing alpha gets guessed. If your cutout doesn't have a real alpha channel - say you loaded an RGB image and ComfyUI handed it a default 64×64 mask - the node notices the mask's size doesn't match the cutout and auto-infers a background. It tries white, black, grays, then common chroma colors (green, pink, light blue, and friends) until it finds something that looks like a clean removal. That's the "BG inferred when alpha is missing" demo, and it's genuinely handy for solid-color studio shots or green-screen grabs. Just know it's a heuristic - busy or photographic backgrounds will defeat it, and that's when you should feed a real mask instead.

The mask convention will trip you up. This node treats cutout_alpha as a transparency map where white means "let the base show through." That's the opposite of the white-means-subject masks most segmentation nodes hand you. If you plug a standard BiRefNet-style mask in and the subject comes out as a hole in the base image, your convention is backwards - hit invert_cutout. It exists precisely because this mismatch is so common. When it looks wrong, flip the toggle before you start hunting for bugs elsewhere.

The inputs that matter

Just four things to actually set: base_image, cutout, cutout_alpha, and size_matching_method. invert_cutout is the fix-it switch. If your cutout is already the same size as the base, the method is a no-op; if it's bigger, crop_larger_center keeps the whole subject rather than letting cover_crop shave the edges.

Installing it

Same pack as the size matcher, same install. Via ComfyUI Manager, search "Size Matcher" or size-match-compositing-nodes, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/christian-byrne/size-match-compositing-nodes

Then restart ComfyUI. The only dependency is TensorImgUtils (a small PyPI utility from the same author, installed automatically by Manager; pip install TensorImgUtils if you're doing it by hand). Python 3.10+, zero model downloads.

Where people get burned

  • Subject looks like a hole → mask convention backwards, flip invert_cutout.
  • Edges of your subject got chopped → your size method cropped it; switch to crop_larger_center or center_dont_resize when the cutout is the bigger one.
  • Ugly auto-inferred background → you fed an RGB-only cutout and it guessed. Feed a proper alpha from your segmentation node for real control.

It's a small node with a single job, and it does that job without needing a PhD in tensor formats. If you paste cutouts onto backgrounds more than once a month, it'll save you more time than most "major" packs.

Categoryimage

Inputs (5)

NameTypeDefaultDescription
base_imageIMAGE
cutoutIMAGE
cutout_alphaMASK
size_matching_methodCOMBO7 options: cover_crop_center, cover_crop, center_dont_resize, fill, fit_center, crop_larger_center, +1
invert_cutoutBOOLEANfalse

Outputs (1)

NameTypeDescription
IMAGEIMAGE