Nodes/KJNodes for ComfyUI/Batch Uncrop Advanced
ComfyUI Node Runs on cloud

Batch Uncrop Advanced

Pasting detail crops back where they came from

By kijai·Created 3 years ago·Updated about 4 hours ago· 2,930
Batch Uncrop Advanced
  • original_images
  • cropped_images
  • cropped_masks
  • combined_crop_mask
  • bboxes
  • combined_bounding_box
  • IMAGE
border_blending0.25
crop_rescale1.00
use_combined_maskfalse
use_square_masktrue

If you've cropped a small region out of a bigger image to run a detail pass on it - upscaling a face, inpainting a small area at higher effective resolution - you eventually need to put that region back. Batch Uncrop Advanced is the paste-back half of that pattern: it takes your processed crops and composites them back into their original images, at their original positions, with a blended seam so the edge doesn't look like a sticker.

Why you'd want this

This is the standard "detailer" workflow, generalized and batched: crop a region tight, run something expensive or high-detail on just that small piece, then stitch it back into the full-size image without a visible seam. Doing this by hand - repositioning a crop and feathering the edge manually - is exactly the kind of fiddly, error-prone step you want a node handling for you, especially across a whole batch at once rather than one image at a time.

It has no author-written description in the node itself, so what follows is read directly off its inputs and outputs.

How it works

For each item in the batch, the node takes the cropped_images (your processed crop) and pastes it into the corresponding original_images at the location described by bboxes, blending the seam according to border_blending and using cropped_masks to know which parts of the crop should actually composite in versus which are just crop padding. crop_rescale accounts for any resizing your crop went through during processing, so the paste-back lands at the correct scale relative to the original image rather than assuming the crop came back at exactly the size it left at.

The inputs and outputs that matter

  • original_images - the full-size images to paste back into.
  • cropped_images - the processed crops, one per original.
  • cropped_masks - per-crop masks marking what should composite from the crop.
  • combined_crop_mask - a combined mask across the batch, used when use_combined_mask is enabled.
  • bboxes - the bounding-box data describing where each crop came from in its original image. This has to come from somewhere upstream that outputs BBOX type - a mask-to-bounding-box node, most likely, rather than the raw masks a crop node like Image Crop By Mask Batch gives you directly.
  • border_blending (0–1, default 0.25) - how much the seam between crop and original is feathered.
  • crop_rescale (0–10, default 1) - corrects for scale mismatch if the crop was resized before processing.
  • use_combined_mask (boolean, default false) and use_square_mask (boolean, default true) - control how masking is applied during the paste (a single combined mask across the batch vs. per-item masks, and whether the mask is treated as a square region vs. its actual shape).
  • combined_bounding_box (optional) - a single bbox covering the combined region, when working with use_combined_mask.

One output: IMAGE - the original images with the processed crops composited back in.

How to install it

  • ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r ComfyUI-KJNodes/requirements.txt (portable: python_embeded\python.exe -m pip install -r ComfyUI\custom_nodes\ComfyUI-KJNodes\requirements.txt), then restart.

No models needed - this is compositing logic.

Common issues & troubleshooting

A visible seam despite blending. Raise border_blending - at the low default (0.25) the feather is subtle, and a crop with a sharp change in tone or detail at its edge will still show a line. Also check crop_rescale matches what actually happened to the crop; a scale mismatch will misalign the paste before blending even has a chance to help.

Crop lands in the wrong place, or the wrong size, in the final image. This traces back to bboxes - if that data doesn't correctly describe where the crop was originally taken from (wrong coordinate space, or bboxes generated against a differently-sized image than what you're pasting into), the paste-back will be off no matter how you tune the blending settings.

Only part of the crop shows up, or none of it does. Check cropped_masks (or combined_crop_mask if use_combined_mask is on) - this node uses the mask to decide what from the crop actually composites in. A mostly-empty or all-zero mask here means little to nothing gets pasted, even though the crop image itself is fine.

CategoryKJNodes/masking

Inputs (10)

NameTypeDefaultDescription
original_imagesIMAGE
cropped_imagesIMAGE
cropped_masksMASK
combined_crop_maskMASK
bboxesBBOX
border_blendingFLOAT0.250–1
crop_rescaleFLOAT1.000–10
use_combined_maskBOOLEANfalse
use_square_maskBOOLEANtrue
combined_bounding_boxoptBBOX

Outputs (1)

NameTypeDescription
IMAGEIMAGE