Nodes/InsertAnything-ComfyUI-official/InsertAnything - Crop Back
ComfyUI Node

InsertAnything - Crop Back

InsertAnything Crop Back

By mo230761·Created about a year ago·Updated about a year ago· 26
InsertAnything - Crop Back
  • raw_image
  • old_tar_image
  • tar_box_yyxx_crop
  • crop_params
  • IMAGE

The "stitch" in crop-edit-stitch

Every good ComfyUI edit workflow is secretly crop-edit-stitch: cut out the region that changes, edit it in isolation, paste it back. Crop Back is that last step for the InsertAnything pack. Its sibling FillProcess builds a two-image "diptych" - your reference object on the left, a crop of your scene on the right - the sampler regenerates that whole frame, and Crop Back takes the right half of the output, resizes it back to its original geometry, and stamps it into the untouched copy of your photo.

That last bit is the whole point. Crop Back pastes into old_tar_image, a pristine copy FillProcess made before any resizing happened. So every pixel outside your mask region comes back to you exactly as it was: no full-frame VAE round-trip, no background drift. It's the same guarantee that made crop-and-stitch the community's default inpainting pattern - the unmasked part of the image isn't touched, not even by an encode/decode pass.

Inputs and output

Four inputs, one output. You don't set any of these by hand - you wire them from FillProcess and the sampler:

  • raw_image - the full generated diptych straight off VAEDecode. Crop Back keeps the right half, because the reference object lives on the left.
  • old_tar_image - the untouched original, from FillProcess's third output.
  • tar_box_yyxx_crop - a BOX in original-image coordinates that says where to paste.
  • crop_params - the geometry FillProcess recorded when it squared up and padded the crop (its H1/W1/H2/W2 bookkeeping). Crop Back uses it to undo the padding, not just resize to fit.

The single IMAGE output is your final composited photo; send it to SaveImage.

One small thing worth knowing: the paste carries a 2-pixel margin inside the box, so the seam lands on preserved original pixels instead of the regenerated edge. It's subtle, but it's the difference between a clean blend and a visible halo.

Wiring it

FillProcess (image, mask)        → InpaintModelConditioning → KSampler → VAEDecode → raw_image
FillProcess (old_tar_image,
             tar_box_yyxx_crop,
             crop_params)        → Crop Back → SaveImage

Install

ComfyUI Manager: search for InsertAnything (or Install via Git URLhttps://github.com/mo230761/InsertAnything-ComfyUI-official.git). Manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/mo230761/InsertAnything-ComfyUI-official.git

Restart ComfyUI, then drop the shipped InsertAnything.json into ComfyUI/user/default/workflows. The pack ships no requirements.txt but imports cv2 and diffusers at load time, so if it fails to import, install opencv-python diffusers into ComfyUI's Python env. The workflow also expects flux1-fill-dev (fp8), flux1-redux-dev + SigLIP vision, the SD3 text encoders, flux-ae, and the insert-anything-lora.safetensors from the paper's HuggingFace page (WensongSong/Insert-Anything). Budget ~26 GB VRAM for the standard route.

Gotchas

  • Don't hand-build the BOX or crop_params. They're internal geometry. Feed Crop Back a box that doesn't match what FillProcess recorded and the paste lands in the wrong place or the resize math goes sideways. Always run the pair.
  • Use the matching pipeline. This node pairs with FillProcess (the 768×768 one). If you're running the no-scaling graph, use Crop Back (No Scaling) instead - it takes three inputs, no crop_params, because the geometry was never resized in the first place.
  • If the composited result looks soft, the culprit is upstream: the scaled pipeline downsampled your crop to 768×768 before sampling. That's exactly the trade the pack's no-scaling variant exists to fix.
Categorysd

Inputs (4)

NameTypeDefaultDescription
raw_imageIMAGE
old_tar_imageIMAGE
tar_box_yyxx_cropBOX
crop_paramsCROP_PARAMS

Outputs (1)

NameTypeDescription
IMAGEIMAGE