Image Paste By BBox Mask
Paste the inpainted crop back where it belongs
- paste_image
- base_image
- bbox_mask
- paste_mask
- image
- mask
This is the node that finishes the classic crop-and-inpaint loop: crop a region, regenerate it at high resolution, and paste the result back over the original so everything outside the region stays bit-identical. Image Paste By BBox Mask is the "put it back" step - it takes your processed crop, your original base image, and a mask whose bbox says where the crop came from, and composites the crop into place with full control over position, scale, rotation, and opacity.
It's from ComfyUI 1hewNodes (solo dev 1hew, bilingual README, active development). It's been in the pack since early versions and is genuinely the one you'll reach for.
How it works
The bbox_mask tells the node where on the base image the crop belongs. The paste image is composited at that location, then refined by the transform controls: position_x/position_y offset the placement, scale resizes the pasted image, rotation spins it (handy when a crop box isn't perfectly axis-aligned), and opacity fades it in. The whole composite is then blended back onto the base.
Alpha handling is the part that separates this from a dumb paste. The paste image's own alpha channel is used if present, and an optional paste_mask gates the paste region further - the two are multiplied, so the final composite is only as strong as both allow. With apply_paste_mask on, the paste respects the mask's soft edge; with it off you get a hard-rect paste. That alpha path is why a regenerated eye crop can melt into the surrounding face instead of showing a rectangle seam.
Outputs are the composited image and the mask of the paste region - so you can see exactly where and how strongly the paste landed, or use that mask for further processing. Batch counts cycle, so one base can host many crops.
The inputs that matter
- paste_image - the crop being placed.
- base_image - the original, untouched everywhere outside the paste.
- bbox_mask - defines placement.
- position_x / position_y, scale, rotation, opacity - the transform dials.
- apply_paste_mask - respect the mask edge when compositing.
- paste_mask - optional, gates the paste region.
Outputs: image, mask.
Installing it
ComfyUI Manager → search "1hew" / "ComfyUI 1hewNodes" → install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
Heavy pack requirements (opencv, scikit-image, plus ultralytics/rembg/transformers for other nodes) make first install slow; this node needs PIL/numpy/torch. No models. Needs current ComfyUI.
Gotchas
- Seam/hard edge despite a mask - check
apply_paste_mask. Off = hard rectangular paste by design. - Paste lands in the wrong spot -
position_x/yoffset the bbox-derived location, and negative values are allowed. If your mask is noisy, the bbox can be off by itself; clean the mask first. - "Base vs. pad, again" - if you're seeing a colored background where the original should be, you grabbed Image Pad By BBox Mask instead, which pads onto a canvas rather than compositing over a base. Wrong tool, different result.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| paste_image | IMAGE | — | |
| base_image | IMAGE | — | |
| bbox_mask | MASK | — | |
| position_x | INT | 0-4096–4096 | — |
| position_y | INT | 0-4096–4096 | — |
| scale | FLOAT | 1.000.1–10 | — |
| rotation | FLOAT | 0.00-3600–3600 | — |
| opacity | FLOAT | 1.000–1 | — |
| apply_paste_mask | BOOLEAN | false | — |
| paste_maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |