Mask Paste by BBox Mask
Paste a mask back where it came from, no coordinates needed
- paste_mask
- bbox_mask
- base_mask
- mask
Everything in mask-based editing is crop-paste. You crop a region out, fix it, and need to put it back in exactly the same place. The "exactly the same place" is where most people end up typing bounding-box coordinates into a string node and praying. Mask Paste by BBox Mask (1hew_MaskPasteByBBoxMask) removes the math: you give it the mask to paste, a bbox mask that marks where it goes, and it lands in the right spot.
It's the direct inverse of the pack's Mask Crop by BBox Mask, and the two are meant to be used as a pair - crop here, edit, paste back.
How it works
The bbox_mask input defines the destination. The node finds the minimal rectangle around its white pixels, resizes your paste_mask to exactly that box (LANCZOS, so it snaps to the region), and pastes it onto a base canvas. If you don't connect base_mask, it starts from a blank (all-black) canvas at the bbox's size - so the output is just your paste sitting where the box said it should.
The base mask is the detail that makes this compositing-friendly rather than just "crop and drop": connect the original full-scene mask and you get the paste blended onto it, which is exactly the "restore my edited region into the original" flow. Batch-wise it broadcasts the way the pack's mask nodes all do - each batch item gets its corresponding paste, box, and base.
Inputs and outputs
- paste_mask - the mask you're putting down.
- bbox_mask - where it goes, defined by its white bounding box.
- base_mask (optional) - the canvas to paste onto. Blank when omitted.
- mask - the result.
Installing it
It's part of the 1hewNodes pack:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
or via ComfyUI Manager ("1hewNodes"), then restart. No models involved.
Where it fits
The cleanest example is regional inpainting. Crop an eye region with Image Crop With BBox Mask, inpaint it at high resolution, then paste the edited mask back through this node so the next stage knows the exact region you changed. Chain it with the image-side sibling Image Paste By BBox Mask and you have a full crop-process-restore round trip where neither the coordinates nor the mask ever drift.
What to watch for: because the paste is resized to the bbox, the box's aspect ratio matters. If your bbox mask is a different shape than your paste, you'll get a stretched paste - that's by design (it fills the box), so keep the box and the paste from the same source if you want a distortion-free result. And if the bbox mask has no white pixels at all, the node returns the base unchanged instead of erroring, which is the pack's standard way of saying "nothing to do here."
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| paste_mask | MASK | — | |
| bbox_mask | MASK | — | |
| base_maskopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |