Image Crop Merge
Put the processed crop back where it came from
- cropped_image
- original_image
- mask
- IMAGE
Crop-and-paste workflows have a silent killer: after you crop a region, run it through some node, and try to paste it back, the paste rarely lines up. UC_ImageCropMerge exists so you don't hand-compute the paste math - give it the processed crop, the original image, and the crop's coordinates, and it resizes the crop to fit and merges it back into the right spot. This is the "put it back" half of a face-detail or region-inpaint loop.
It pairs naturally with the pack's bounding-box and crop nodes: crop a face region, upscale or inpaint it, then merge the result back over the original at the same coordinates. The resize-to-region behavior is the key feature - your processed crop can come back at a different resolution than the original crop was, and the node fits it to the destination region so you don't have to.
How it works
cropped_image is resized to the destination region defined by crop_x, crop_y, crop_width, crop_height (all in original-image pixels), using resize_method (default lanczos), and pasted into original_image at that spot. An optional mask soft-blends the merge; leave it disconnected and the region is replaced completely.
The inputs that matter
cropped_image- the processed crop.original_image- the full image receiving it.crop_x/crop_y/crop_width/crop_height- the region in original-image pixels. These areforce_inputsockets, so they're meant to be wired from whatever computed the crop - wire them from the same crop/bounding-box node that produced the crop and they'll always agree.mask- optional blend mask for the region.
Output: a single IMAGE with the merged result.
Installing it
ComfyUI Manager → search "ComfyUI-UtilsCollection", or:
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection
Restart. Deps: opencv-python and typing-extensions, no models. Newer-API pack - keep ComfyUI updated.
Where it bites: stale coordinates. If the crop node and this node get their crop_x/crop_y from different sources - or one of them is a hardcoded widget - the region drifts and the "fixed" face lands half a chin off. Wire the coordinates from the same socket everywhere. Also remember: it resizes the crop to the region, so an extreme aspect mismatch between them will distort the crop; keep the destination region near the crop's aspect ratio unless distortion is the point.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| cropped_image | IMAGE | Processed crop to resize and merge into the original image region. | |
| original_image | IMAGE | Full image that receives the processed crop. | |
| crop_x | INT | 00–16384 | Left edge of the crop region in original-image pixels. |
| crop_y | INT | 00–16384 | Top edge of the crop region in original-image pixels. |
| crop_width | INT | 5121–16384 | Width of the destination crop region; the processed crop is resized to this width. |
| crop_height | INT | 5121–16384 | Height of the destination crop region; the processed crop is resized to this height. |
| resize_method | COMBO | lanczos | Interpolation used when resizing the processed crop to the destination region. |
| maskopt | MASK | Optional blend mask for the crop region; disconnected replaces the region completely. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |