Nodes/ComfyUI Level Pixel/Inpaint Stitch [LP]
ComfyUI Node

Inpaint Stitch [LP]

Pasting the edited fragment back without touching anything else

By LevelPixel·Created 2 years ago·Updated 6 months ago· 31
Inpaint Stitch [LP]
  • crop_data
  • inpainted_image
  • image

This is the second half of the pair, and it only makes sense alongside InpaintCrop-LP. Crop pulls a fragment out of your image around a mask; this node puts whatever you did to that fragment back into the original, at the exact position and scale it came from - and, crucially, without touching a single pixel outside that region.

Why "doesn't touch anything else" is the whole point

The pattern this pack ported (credited in the README to lquesada's ComfyUI-Inpaint-CropAndStitch) became the standard way to combine mask-based inpainting with modern edit models specifically because of this property. An edit model re-encodes and regenerates a whole frame when you run it directly, which means even pixels you never wanted changed drift a little every time - and that drift compounds across a chain of edits. Compositing the result back with Inpaint Stitch sidesteps that entirely: the region outside your crop is never re-encoded, never passed through a VAE again, never regenerated. It's a pixel-level paste, not a second render.

How it works

InpaintStitch-LP reads the bounding box, original scale, and blend width that InpaintCrop-LP stashed away in its crop_data output. It resizes your edited fragment back to the exact size and position that patch of the image originally occupied, composites it in using the feather width baked in at crop time (the mask_blend_pixels value you set on the Crop node), and leaves everything outside that boundary bit-for-bit identical to the source.

The inputs and outputs that matter

  • crop_data - must come from the matching InpaintCrop-LP call upstream. This isn't a generic parameter bundle; it's a token specific to that one crop operation, and it needs to travel from Crop to Stitch without being rerouted through anything that might alter it.
  • inpainted_image - whatever you ran your sampling, editing, or manual repaint on top of the cropped fragment. It doesn't need to be the exact same pixel dimensions the Crop node handed you - if you upscaled the fragment before generating (to squeeze more detail out of a small masked area), Stitch resizes it back down to fit automatically. That's the reason the metadata and the pixels travel as two separate things instead of one.
  • Output - image, the full original image with just the masked region replaced.

How to install it

ComfyUI Manager: search "ComfyUI Level Pixel" or ComfyUI-LevelPixel, install, restart - auto-updates through Manager's "Update ALL." Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/LevelPixel/ComfyUI-LevelPixel.git

Restart ComfyUI. No models, pure image compositing logic, ported alongside InpaintCrop-LP from the same upstream project.

Common issues & troubleshooting

The stitched result looks shifted or misaligned. By far the most common cause is crop_data coming from the wrong crop call - if you have more than one Inpaint Crop node in a graph, double-check you're feeding Stitch the crop_data from the same crop it's meant to pair with, not a different one. Also check nothing in between Crop and Stitch is quietly resizing or cropping inpainted_image further; keep that path as clean as possible.

You want a softer or harder seam and this node has no blend setting. That's intentional - the blend width lives on the Crop side, baked into crop_data via mask_blend_pixels. If the seam isn't right, go back and adjust it on InpaintCrop-LP, then re-run; there's nothing to tune here.

You upscaled the fragment before editing and worried you need to downscale it back yourself first. You don't - resizing the edited fragment back to its original footprint is exactly what this node does automatically, using the scale information stored in crop_data. Feed it the upscaled result directly.

CategoryLevelPixel/Inpaint

Inputs (2)

NameTypeDefaultDescription
crop_dataCROPDATA
inpainted_imageIMAGE

Outputs (1)

NameTypeDescription
imageIMAGE