Nodes/ComfyUI 1hewNodes/Image Pad By BBox Mask
ComfyUI Node

Image Pad By BBox Mask

Drop a local crop back onto the full canvas, gaps and all

By 1hew·Created about a year ago·Updated 7 days ago· 33
Image Pad By BBox Mask
  • paste_image
  • bbox_mask
  • image
pad_color1.0

When you crop a region out of an image, do something to it, and want it back in place - with the rest of the canvas intact - you're doing what Image Pad By BBox Mask does. It takes a small image (your processed crop), a mask whose bounding box says where that crop belongs, and places the crop back onto a full-size canvas matching the mask, filling everything outside the bbox with a color you choose.

It's from ComfyUI 1hewNodes (solo dev 1hew, bilingual README, active development - this one landed in v3.17.0). It's the "put it back" half of the crop/pad/paste family, and it's newer and more niche than its sibling nodes.

How it works

The bbox_mask does double duty: its bounding box defines both the placement and the size of the target region on the full canvas, and its own dimensions define the output canvas size. The paste image is fit into that bbox - aspect-preserving, so if the crop's ratio doesn't match the box, it's scaled to fit within it. Then the whole thing is laid onto a canvas the size of the mask, with pad_color filling every uncovered pixel (default white).

The flow it's designed for is straightforward: full image → crop region → generate/inpaint/edit the region in isolation → this node to put the result back at the right spot on a full canvas. The output canvas inherits the mask's resolution, so the result lines up with the original frame.

One thing to keep in mind: this node fills the rest of the canvas with a solid color - it does not composite the crop over an existing base image. If you want the original image as the backdrop (with the crop pasted over it), that's what Image Paste By BBox Mask is for. These two are easy to confuse, and they're not interchangeable.

The inputs that matter

  • paste_image - your processed crop (the small image being placed).
  • bbox_mask - the mask whose bbox defines placement and whose size defines the output canvas.
  • pad_color - the fill color for everything outside the bbox (default "1.0", white).

Output is a single image - the full-canvas result.

Installing it

ComfyUI Manager → search "1hew" / "ComfyUI 1hewNodes" → install → restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes

Pack requirements are heavy (opencv, scikit-image, ultralytics, rembg for other nodes) - first install is slow; this node needs PIL/torch. No models. Requires current ComfyUI (modern node API).

Gotchas

  • Wrong output: everything's one color except the crop - that's literally what this node does. It's a pad-onto-canvas, not a composite. Use the paste node for compositing over a base.
  • Empty mask - if the mask has no foreground at all, there's no bbox, and the node just returns a solid canvas of pad_color. Check your mask before you debug your pipeline.
  • The crop looks squished - it's fit aspect-preserving inside the bbox, so mismatched ratios leave gaps (filled with pad_color) rather than stretching. If you want it to fill the box exactly, resize the crop to the box ratio first.
Category1hewNodes/image/crop

Inputs (3)

NameTypeDefaultDescription
paste_imageIMAGE
bbox_maskMASK
pad_colorSTRING1.0

Outputs (1)

NameTypeDescription
imageIMAGE