ComfyUI Node
Fit Image into BBox Mask
This node fits an image inside the bounding box region of a mask and places it into a destination image (or a blank canvas). It’s useful for workflows where you want to insert or align a smaller image (e.g. pose, object, logo, patch) into a specific masked region while keeping correct proportions. This node does the following:
Fit Image into BBox Mask
- source
- mask
- destination
- composite
- fitted_source
- placed_mask
- x
- y
- w
- h
◄modefit►
◄align_xcenter►
◄align_ycenter►
◄offset_x0►
◄offset_y0►
◄threshold0.50►
◄pad0►
◄use_source_alphafalse►
◄antialiaslanczos►
◄canvas_w1024►
◄canvas_h1024►
CategoryvsLinx/inpaint
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| source | IMAGE | The image you want to insert (e.g. pose, object, decal). | |
| mask | MASK | Defines where the image will be placed. The white area determines the bounding box. | |
| mode | COMBO | fit | fit scales the image inside the mask’s box (no crop). fill covers the box completely (may crop edges). |
| align_x | COMBO | center | Alignment on the x axis of the fitted image inside the box if the aspect ratio doesn’t match perfectly. |
| align_y | COMBO | center | Alignment on the y axis of the fitted image inside the box if the aspect ratio doesn’t match perfectly. |
| offset_x | INT | 0-4096–4096 | Manual pixel offset on the x axis for fine-tuning the placement. |
| offset_y | INT | 0-4096–4096 | Manual pixel offset on the y axis for fine-tuning the placement. |
| threshold | FLOAT | 0.500–1 | Mask brightness threshold for detecting the box. 0.5 works for most cases. |
| pad | INT | 00–4096 | Expands the bounding box outward by N pixels. |
| use_source_alpha | BOOLEAN | false | If true, respects transparency in the source image during paste. |
| antialias | COMBO | lanczos | Resampling method used when resizing the source image. |
| destinationopt | IMAGE | The image you’re compositing onto. If not provided, a blank canvas is created. | |
| canvas_wopt | INT | 102416–8192 | Canvas width when no destination image is given. |
| canvas_hopt | INT | 102416–8192 | Canvas height when no destination image is given. |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| composite | IMAGE | — |
| fitted_source | IMAGE | — |
| placed_mask | MASK | — |
| x | INT | — |
| y | INT | — |
| w | INT | — |
| h | INT | — |