Paste with Metadata
Paste an edit back where it came from — and leave every other pixel alone
- original_image
- crop_image
- crop_info
- mask
- exclude_mask
- Composited Image
Paste with Metadata is the other half of Detail Stitch, and it's the half that makes the whole trick work. Crop a region, regenerate it at full model resolution, and this node drops the result back into the original at the exact position the crop came from. Everything outside the pasted box stays bit-identical - which is the entire reason anyone builds a crop-and-stitch pipeline instead of just feeding a whole frame to an edit model.
It's the answer to the problem the modidex inpainting doc keeps circling: whole-image edit models like Qwen and Kontext return the unmasked areas close but not identical, and the drift compounds every time you chain another edit. Masked, local regeneration doesn't have that failure mode at all, because the untouched pixels are literally never touched.
How it works
It takes the CROP_INFO object that Crop with Metadata emits and reads the recorded x, y, width, height, plus the original image's dimensions. If the edited crop doesn't match the recorded size, it gets bilinear-resized into place. Then three things can modify the paste:
- mask - the blend control. The paste becomes
mask * crop + (1 - mask) * original, so a feathered mask softens the seam. The example workflow grows and blurs a SAM mask (GrowMaskWithBlur) precisely for this, and it's the difference between an obvious patch and an invisible edit. - exclude_mask - multiplies the main mask to zero:
mask * (1 - exclude_mask). Handy for keeping part of the original inside the crop box (an object you don't want regenerated) while regenerating the rest. - longer_edge - the sleeper feature. If set, the original image is rescaled so its longest edge hits that many pixels, and the crop coordinates scale along with it. That lets you regenerate the whole original at higher resolution, then paste the edited crop in at the new scale.
The inputs you'll actually set: original_image, crop_image, and crop_info (required), then the three optionals above. The single output is Composited Image, which goes straight to a SaveImage or PreviewImage.
Installing it
Same pack as the crop node - ComfyUI Manager (search Detail Stitch) or:
cd ComfyUI/custom_nodes
git clone https://github.com/mancusog/comfyui-detail-stitch.git
Restart ComfyUI. Zero extra dependencies and no model files; it's tensor slicing and interpolation.
Where people get burned
- Crop and paste sizes disagree. If you resized the crop between the two nodes, the paste auto-resizes it back - which softens your hard-won detail. Keep the edited crop at the same resolution the crop node emitted, or use
longer_edgedeliberately. - A hard rectangular seam. You skipped the mask. Without a feathered mask you get a clean but visible rectangle; that's fine for a true crop edit, wrong for most photo work.
- Mask size mismatches. The node handles masks sized to the original or to the crop, but a mask in the wrong aspect ratio will be stretched. Size matters.
longer_edgeset to 0 means "don't touch the original" - that's the default, and it's the mode to stay in until you know you need the rescale.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| original_image | IMAGE | — | |
| crop_image | IMAGE | — | |
| crop_info | CROP_INFO | — | |
| maskopt | MASK | — | |
| exclude_maskopt | MASK | — | |
| longer_edgeopt | INT | 00–8192 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Composited Image | IMAGE | — |