Nodes/ComfyUI-I2I-slim/Paste (Combine and Paste)
ComfyUI Node

Paste (Combine and Paste)

The paste node that hides your inpaint seams

By GeraldWie·Created about a year ago·Updated about a year ago· 0
Paste (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

Cut-paste inpainting is a two-node job, and the paste is where quality lives or dies. Cut grabs a region and regenerates it; this node - Paste (Combine and Paste) - is the half that puts the result back so it doesn't look pasted. If your cut-paste workflow has visible seams or a region that's the right content but the wrong color, this is the node doing the heavy lifting, and it's worth understanding what's under the hood.

Where it sits

The chain is LoadImage → a mask → Cut → KSampler → VAE Decode → this node → Preview. It takes five image inputs that look redundant and are anything but:

  • decoded_vae - what your sampler produced, after VAE Decode. This is the new content.
  • Original_Image and Cut_Image - the untouched original, and the cut that Cut handed to the sampler.
  • Cut_Mask and region - the mask, and the geometry telling the node where the crop came from.

How it works

Internally it runs a short, deliberate pipeline. First it applies the mask operation (op, default union (max)) to both the decoded image and the original cut, so everything outside the mask is discarded. Then comes the interesting step: a per-channel mean/std color correction that re-matches the freshly generated pixels to the original cut, scaled by color_xfer_factor. That's the anti-seam move - it's the same reason inpaint results get the classic "grey box" color shift when this step is missing. Finally it resizes the corrected cut to the mask's bounding box and composites it onto the original at the right coordinates.

Inputs that matter

  • color_xfer_factor (default 1, range 0-2) - how hard to force the pasted region's color statistics toward the original. 1 is a full match and is right for most jobs; if your paste still stands out, make sure this isn't sitting below 1.
  • resize_behavior - resize stretches to the mask's box and is the sensible default. keep_ratio_fill / keep_ratio_fit preserve aspect ratio; source_size drops the region in at its generation size.
  • op - leave on union (max) unless you're deliberately combining masks.
  • clamp_result / round_result - leave at defaults.

The output is FinalOut, your finished composited image. The optional mask_mapping_optional matters only when you came from Mask Ops with separate_mask on: it keeps Cut's mapping so this node knows which generated image belongs to which mask region.

Installing it

It ships in ComfyUI-I2I-slim, GeraldWie's slimmed fork of ManglerFTW's ComfyI2I. Via Manager:

Manager → Install Custom Nodes → search "ComfyUI-I2I-slim" → Install → Restart

or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/GeraldWie/ComfyUI-I2I-slim
cd ComfyUI-I2I-slim
pip install -r requirements.txt

No model files needed. One trap: requirements.txt lists tensorflow and scikit-image that the code never imports - the real deps are numpy, torch, torchvision, opencv and PIL.

Common issues

  • Pasted region is a different color than its surroundings - the internal color correction should mostly kill this at factor 1. If it doesn't, suspect your VAE decode itself: encode/decode cycles are a classic source of the color shift.
  • "image_to_paste does not have an entry for mask index i" - you generated fewer images than there are mask regions. Fix the batch count, or wire up mask_mapping_optional when you split a mask with separate_mask.
  • Region comes back the wrong shape - that's resize_behavior; switch from resize to a keep-ratio option.
CategoryI2I-slim

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