Nodes/comfyui-311-inpaint/Add Margins 311
ComfyUI Node

Add Margins 311

Add margins to an image and its mask. Default (square_longest): black 1:1 canvas from the longest side, then scale_by 1.25, content centered — matches ImageSize→ScaleByAspectRatio→Upscale By→Align. Also supports add_margins (px/%) and target_size.

By Latentnaut·Created 26 days ago·Updated 26 days ago· 0
Add Margins 311
  • image
  • mask
  • IMAGE
  • MASK
size_modesquare_longest
scale_by1.25
margin_layoutsymmetric
unitpixels
extra_width0
extra_height0
left0
left_unitpixels
right0
right_unitpixels
top0
top_unitpixels
bottom0
bottom_unitpixels
target_width512
target_height512
fill_color#000000
haligncenter
valigncenter
Category311/Inpaint

Inputs (21)

NameTypeDefaultDescription
imageIMAGE
size_modeCOMBOsquare_longestsquare_longest: square canvas = longest_side * scale_by, center content. add_margins: expand with symmetric or custom side margins. target_size: fit onto target_width x target_height.
scale_byFLOAT1.250.01–8Multiplier for longest side when size_mode=square_longest (default 1.25).
margin_layoutCOMBOsymmetricsymmetric: extra_width/height split equally L/R and T/B. custom: independent left/right/top/bottom (each with own unit).
unitCOMBOpixelsUnit for extra_width / extra_height when margin_layout=symmetric.
extra_widthINT00–8192Total added width (split L/R). Used when size_mode=add_margins + symmetric.
extra_heightINT00–8192Total added height (split T/B). Used when size_mode=add_margins + symmetric.
leftFLOAT00–8192Left margin (custom layout).
left_unitCOMBOpixels2 options: pixels, percent
rightFLOAT00–8192Right margin (custom layout).
right_unitCOMBOpixels2 options: pixels, percent
topFLOAT00–8192Top margin (custom layout).
top_unitCOMBOpixels2 options: pixels, percent
bottomFLOAT00–8192Bottom margin (custom layout).
bottom_unitCOMBOpixels2 options: pixels, percent
target_widthINT5121–8192Canvas width when size_mode=target_size.
target_heightINT5121–8192Canvas height when size_mode=target_size.
fill_colorSTRING#000000Canvas fill color as #RGB or #RRGGBB.
halignCOMBOcenter3 options: center, left, right
valignCOMBOcenter3 options: center, top, bottom
maskoptMASK

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK