Nodes/ComfyUI-Inpaint-CropAndStitch/✂️ Inpaint Stitch
ComfyUI Node

✂️ Inpaint Stitch

Pastes your inpaint back without touching anything else

By lquesada·Created 2 years ago·Updated 2 months ago· 1,136
✂️ Inpaint Stitch
  • stitcher
  • inpainted_image
  • image

Inpaint Stitch (class InpaintStitchImproved, the "✂️ Inpaint Stitch" node) is the back half of the crop-and-stitch pair. Inpaint Crop cut a region out, you sampled on it, and now Stitch drops the result back into the original image exactly where it came from - resizing and un-transforming it as needed, blending the edges, and leaving every unmasked pixel bit-for-bit identical. That last bit is the whole reason people run this pack instead of a plain composite: the unmasked part of your image never went through VAE encode/decode, so it can't drift.

It is a deliberately dumb node in the best way. Two inputs, one output, nothing to configure. All the intelligence - where the crop lives, how it was scaled, how wide to feather the seam - was decided back in Crop and carried forward in the stitcher bundle. Stitch just executes it.

How it works

When Crop ran, it recorded everything it did: the bounding box, the scale factor, any outpaint extension, the blend radius. It packed that into the stitcher output. Stitch takes that receipt plus your freshly-inpainted crop, reverses the transform (scales the crop back down or up to fit the hole, moves it to the right spot), and alpha-blends it in using the blur radius Crop already computed. No seams, no one-pixel shifts. The improved version specifically fixed the old node's habit of nudging the paste by a pixel, which is why it exists as a separate class.

Because the blend was set on the Crop side (mask_blend_pixels there), there's genuinely nothing to tune here. If your seam looks off, you go back and adjust Crop, not Stitch.

The inputs and outputs that matter

There are only two inputs and both are mandatory:

  • stitcher (STITCHER) - the bundle from Inpaint Crop's stitcher output. This must come from the same Crop node that produced the image you're stitching, or the geometry won't line up. Don't wire an image into this; it's not an image.
  • inpainted_image (IMAGE) - the sampled/decoded result of your crop. This is whatever came out of your VAE Decode after sampling on cropped_image.

Output: a single image - your original, with only the masked region replaced. Send it to a Save Image, a preview, or straight into the next inpaint pass.

That's the entire node. If you're looking for blend or resize controls here, they moved to the Crop node on purpose.

How to install it

It ships in the same pack as Inpaint Crop, so if you have one you have the other. Otherwise: search ComfyUI-Inpaint-CropAndStitch in ComfyUI Manager and install, or

cd ComfyUI/custom_nodes
git clone https://github.com/lquesada/ComfyUI-Inpaint-CropAndStitch.git

then restart ComfyUI. No models, no extra dependencies - it's plain image compositing (GPL-3.0, by Luis Quesada Torres).

Common issues & troubleshooting

The paste is in the wrong place, wrong size, or garbled. Almost always a mismatched stitcher. It has to be the exact bundle from the Crop node whose crop you sampled - not a different Crop, not a stale one from a duplicated branch. One Crop, one Stitch, wired straight through.

Visible seam or hard edge. The blend is controlled upstream. Go back to Inpaint Crop and raise mask_blend_pixels (it grows and blurs the stitch mask). Stitch itself has no seam control by design.

I can still see the old image bleeding through the fix. That's the mask not being fully opaque back at Crop - grey values your eye reads as white still let the original show through. Fix the mask (verify it's true #FFFFFF), not the stitch.

Colors shift slightly in the pasted region. Expected and unavoidable to a small degree: the crop did round-trip the VAE (only the unmasked surround is protected). Use the right VAE for your model and an inpainting checkpoint, and keep the region at native resolution. The point of this pair isn't zero VAE loss on the fix - it's that the rest of the image is spared entirely.

Categoryinpaint

Inputs (2)

NameTypeDefaultDescription
stitcherSTITCHER
inpainted_imageIMAGE

Outputs (1)

NameTypeDescription
imageIMAGE