ComfyUI Node

Uncrop Image

Paste the edit back where it belongs

By nova452·Created 3 months ago·Updated 28 days ago· 509
Uncrop Image
  • original_image
  • original_mask
  • cropped_image
  • uncropped_image

The crop-and-stitch pattern is how you get detail work done: crop a small region, run it at the model's native resolution where it gets a huge generation budget, then paste the result back into the original frame. The pasting step is where most people hand-roll coordinate math or reach for a heavyweight compositing node. UncropImage from the Rebalance Pack is the paste-back step, done properly: it takes the original full image, the mask that marked the crop region, and the newly generated cropped image, and splices the crop into the original at exactly the right spot.

It's the quiet hero of the pack's image-editing workflows - the same pack that ships the Krea 2 / Ideogram 4 edit conditioning - because that whole editing style is crop → edit → uncrop. And unlike a naive paste, this node keeps every pixel outside the crop untouched, which is precisely the promise that makes masked detail work worth doing in the first place.

How it works

The position is derived from the mask, not guessed: UncropImage finds the bounding box of the original_mask's non-zero region and uses its top-left corner as the paste anchor. The cropped_image is then composited into a clone of the original_image starting at that anchor. It's robust about shapes: the original and cropped tensors can differ in batch size (it broadcasts a single cropped image across the batch or expands the original as needed), and it clips the paste to the frame bounds so a crop that's slightly larger than the region it replaces doesn't error - it just trims.

The outputs are what make it useful: uncropped_image, a full-size tensor with the edited region swapped in and everything else bit-identical to the original. In an inpaint context, "everything else untouched" is the whole point - that's the property that lets you do a 64-pixel eye at full detail without the model touching the rest of the face.

The inputs that matter

  • original_image - the full frame you started with.
  • original_mask - the mask that defined the crop region. Its bounding box sets the paste anchor.
  • cropped_image - the edited/upscaled region to paste in.

Install

Part of the Rebalance Pack. ComfyUI Manager: search "ComfyUI-Conditioning-Rebalance" (or "Rebalance Pack"). Manual:

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

Restart afterwards. No models, no extra dependencies - pure tensor slicing.

Troubleshooting

The common failure is a coordinate mismatch, and it usually traces back to the mask, not this node. If the cropped region was made by cropping an image at a specific box, the original_mask you feed here must mark that same box - if it's a soft/feathered mask, the bounding box is still the box, which is what matters, so feathering is fine. If the crop came out of a different source than the mask's box, the paste lands in the wrong place; keep the crop and the mask derived from the same coordinates. Second gotcha: the cropped image is pasted at its natural size - this node doesn't resize it to fit the mask box. If your edit node output a different resolution than the crop, upscale it first. And if you're assembling a full mask-based inpaint loop, pair it with the pack's UncropMask on the mask side so your regenerated mask lines up with your regenerated image.

CategoryRebalance-Pack/image

Inputs (3)

NameTypeDefaultDescription
original_imageIMAGE
original_maskMASK
cropped_imageIMAGE

Outputs (1)

NameTypeDescription
uncropped_imageIMAGE