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.
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)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| size_mode | COMBO | square_longest | square_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_by | FLOAT | 1.250.01–8 | Multiplier for longest side when size_mode=square_longest (default 1.25). |
| margin_layout | COMBO | symmetric | symmetric: extra_width/height split equally L/R and T/B. custom: independent left/right/top/bottom (each with own unit). |
| unit | COMBO | pixels | Unit for extra_width / extra_height when margin_layout=symmetric. |
| extra_width | INT | 00–8192 | Total added width (split L/R). Used when size_mode=add_margins + symmetric. |
| extra_height | INT | 00–8192 | Total added height (split T/B). Used when size_mode=add_margins + symmetric. |
| left | FLOAT | 00–8192 | Left margin (custom layout). |
| left_unit | COMBO | pixels | 2 options: pixels, percent |
| right | FLOAT | 00–8192 | Right margin (custom layout). |
| right_unit | COMBO | pixels | 2 options: pixels, percent |
| top | FLOAT | 00–8192 | Top margin (custom layout). |
| top_unit | COMBO | pixels | 2 options: pixels, percent |
| bottom | FLOAT | 00–8192 | Bottom margin (custom layout). |
| bottom_unit | COMBO | pixels | 2 options: pixels, percent |
| target_width | INT | 5121–8192 | Canvas width when size_mode=target_size. |
| target_height | INT | 5121–8192 | Canvas height when size_mode=target_size. |
| fill_color | STRING | #000000 | Canvas fill color as #RGB or #RRGGBB. |
| halign | COMBO | center | 3 options: center, left, right |
| valign | COMBO | center | 3 options: center, top, bottom |
| maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |