Nodes/ComfyUI vsLinx Nodes/Fit Image into BBox Mask
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:

By vslinx·Created 12 months ago·Updated 27 days ago· 20
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)

NameTypeDefaultDescription
sourceIMAGEThe image you want to insert (e.g. pose, object, decal).
maskMASKDefines where the image will be placed. The white area determines the bounding box.
modeCOMBOfitfit scales the image inside the mask’s box (no crop). fill covers the box completely (may crop edges).
align_xCOMBOcenterAlignment on the x axis of the fitted image inside the box if the aspect ratio doesn’t match perfectly.
align_yCOMBOcenterAlignment on the y axis of the fitted image inside the box if the aspect ratio doesn’t match perfectly.
offset_xINT0-4096–4096Manual pixel offset on the x axis for fine-tuning the placement.
offset_yINT0-4096–4096Manual pixel offset on the y axis for fine-tuning the placement.
thresholdFLOAT0.500–1Mask brightness threshold for detecting the box. 0.5 works for most cases.
padINT00–4096Expands the bounding box outward by N pixels.
use_source_alphaBOOLEANfalseIf true, respects transparency in the source image during paste.
antialiasCOMBOlanczosResampling method used when resizing the source image.
destinationoptIMAGEThe image you’re compositing onto. If not provided, a blank canvas is created.
canvas_woptINT102416–8192Canvas width when no destination image is given.
canvas_hoptINT102416–8192Canvas height when no destination image is given.

Outputs (7)

NameTypeDescription
compositeIMAGE
fitted_sourceIMAGE
placed_maskMASK
xINT
yINT
wINT
hINT