Paste (Combine and Paste)
The paste node that hides your inpaint seams
- decoded_vae
- Original_Image
- Cut_Image
- Cut_Mask
- region
- mask_mapping_optional
- FinalOut
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_ImageandCut_Image- the untouched original, and the cut that Cut handed to the sampler.Cut_Maskandregion- 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-resizestretches to the mask's box and is the sensible default.keep_ratio_fill/keep_ratio_fitpreserve aspect ratio;source_sizedrops the region in at its generation size.op- leave onunion (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_optionalwhen you split a mask withseparate_mask. - Region comes back the wrong shape - that's
resize_behavior; switch fromresizeto a keep-ratio option.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| decoded_vae | IMAGE | — | |
| Original_Image | IMAGE | — | |
| Cut_Image | IMAGE | — | |
| Cut_Mask | IMAGE | — | |
| region | IMAGE | — | |
| color_xfer_factor | FLOAT | 1.00–2 | — |
| op | COMBO | 8 options: union (max), intersection (min), difference, multiply, multiply_alpha, add, +2 | |
| clamp_result | COMBO | 2 options: yes, no | |
| round_result | COMBO | 2 options: no, yes | |
| resize_behavior | COMBO | 5 options: resize, keep_ratio_fill, keep_ratio_fit, source_size, source_size_unmasked | |
| mask_mapping_optionalopt | MASK_MAPPING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| FinalOut | IMAGE | — |