Nodes/ComfyI2I/Combine and Paste
ComfyUI Node

Combine and Paste

The node that puts your inpainted crop back without touching a single unmasked pixel

By ManglerFTW·Created 3 years ago·Updated 2 years ago· 181
Combine and Paste
  • decoded_vae
  • Original_Image
  • Cut_Image
  • Cut_Mask
  • region
  • mask_mapping_optional
  • FinalOut
color_xfer_factor1.0
op
clamp_result
round_result
resize_behavior

Combine and Paste is the last node in ComfyI2I's crop-inpaint-paste loop, and it's the one that decides whether your edit looks bolted on or native. It takes the freshly VAE-decoded output of your inpainted region, resizes it to the bounding box of your mask, runs a quick color correction, and pastes it over the original image. The pixels outside the mask never pass through a model - not even through VAE encode/decode - and that bit-identical unmasked area is exactly why mask-based inpainting still beats full-frame edit models in 2026. An edit model regenerates the whole frame and drifts on every pass; this thing only ever changes what you painted.

How it works

Wire it up as the mirror image of Inpaint Segments: that node crops and upscales each mask region, you VAE Encode → sample → VAE Decode, and this node finishes the job. It takes decoded_vae (your inpainted region out of VAE Decode), Original_Image (the untouched source you're pasting onto), Cut_Image and Cut_Mask (from Inpaint Segments), and region (also from Inpaint Segments - it's the full-res layout of the bounding boxes that tells the node where to paste).

Under the hood it does four things in order: combines the decoded output with Cut_Mask using op, combines the original cut with the same mask, runs a mean/std color correction between them scaled by color_xfer_factor, then pastes the result at the region's location via resize_behavior. The color step is the seam-killer - it nudges the inpainted pixels' color statistics toward the original region so your edit doesn't come back tinted differently from everything around it.

The inputs that actually matter

  • decoded_vae - the inpainted region from VAE Decode. This is the only input that changes frame-to-frame.
  • Original_Image - the untouched source. If you wire the wrong image here you'll paste onto the wrong frame.
  • Cut_Image, Cut_Mask, region - all three come straight from Inpaint Segments. Don't reorder or drop them.
  • color_xfer_factor (0–2, default 1) - how hard to push the edit's color stats toward the original. Raise it toward 2 if your inpaint comes back a visibly different tint; 0 skips the correction entirely.
  • op - the mask combine operation. union (max) is what you want 99% of the time. The example workflow uses multiply_alpha; if you're not sure why you're changing this, leave it alone.
  • resize_behavior - resize is fine for the standard loop. Switch to keep_ratio_fit or keep_ratio_fill if you changed the crop's aspect ratio upstream.

Output is a single FinalOut IMAGE - wire it to Save Image or a preview node.

Install

The pack ships with ComfyUI Manager - search "ComfyI2I" (or ManglerFTW/ComfyI2I) and install. Manual route:

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

Restart ComfyUI and the nodes appear under the I2I category. On Linux or a non-admin Windows account, ComfyUI needs write access to custom_nodes/ComfyI2I/ComfyI2I.py - the pack copies its JS into web/extensions on startup. Two things to know about that requirements file: it drags in tensorflow and scikit-image that the code never imports, so that's a lot of wasted download, and transformers (needed by Mask Ops' text mode) isn't listed at all. The pipeline nodes themselves only need numpy, torch, torchvision and opencv.

Common issues

  • Seams or color shift around the edit. Raise color_xfer_factor toward 2, and feather your mask upstream - a hard mask edge is the number one cause of a visible rectangle.
  • "image_to_paste does not have an entry for mask index i." Your decoded batch doesn't line up with the mask islands. Keep the Inpaint Segments outputs paired and feed all masks through one path; don't split and reorder the batch.
  • The whole frame gets pasted. You forgot the region input, so the node has nothing to localize against. Wire region from Inpaint Segments and it snaps back to the mask boxes.

One honest caveat: the pack's last commit is from late 2023 and it's been quiet since. The mechanism here is simple and self-contained enough that it still runs fine, but if you're building a fresh modern pipeline you'll find the same crop-paste idea, better maintained, in Impact Pack's detailer machinery and in the CropAndStitch pattern that became the community default. Still, for a self-contained I2I loop with zero extra model downloads, Combine and Paste does the one job that matters: your unpainted pixels come back pixel-identical, every single time.

CategoryI2I

Inputs (11)

NameTypeDefaultDescription
decoded_vaeIMAGE
Original_ImageIMAGE
Cut_ImageIMAGE
Cut_MaskIMAGE
regionIMAGE
color_xfer_factorFLOAT1.00–2
opCOMBO8 options: union (max), intersection (min), difference, multiply, multiply_alpha, add, +2
clamp_resultCOMBO2 options: yes, no
round_resultCOMBO2 options: no, yes
resize_behaviorCOMBO5 options: resize, keep_ratio_fill, keep_ratio_fit, source_size, source_size_unmasked
mask_mapping_optionaloptMASK_MAPPING

Outputs (1)

NameTypeDescription
FinalOutIMAGE