Nodes/ComfyUI Fictiverse Nodes/Add Margin With Color
ComfyUI Node

Add Margin With Color

Grow the canvas for outpainting, mask included

By Fictiverse·Created 3 years ago·Updated 17 days ago· 27
Add Margin With Color
  • image
  • OUTPUT_IMAGE
  • MASK
margin_pct10
topfalse
blacktrue

Add Margin With Color pads your image with a strip of solid color - black or white - and hands you both the enlarged image and a mask showing exactly where the new pixels are. On its own that's a "why would I?" operation. Pair the mask with an inpainting pass and you've got a one-node outpainting rig: grow the canvas, inpaint only the strip, and you've extended the image in a direction the model decides.

This is the classic "canvas extend" trick the community uses for vertical outpainting - you add blank canvas above or below, then let an inpaint model fill it in. The mask is the part that makes it work cleanly, because it tells the inpaint sampler only to touch the margin and leave your original pixels alone. Without that mask you'd have to hand-paint a mask or crop the region yourself.

How it works

The node measures your image's height and adds a margin equal to margin_pct percent of that height - so a 1024px-tall image at 10% gains 102px. The margin is added to the top or the bottom (there's no left/right option; it's a vertical strip only), and it's filled with pure black or pure white depending on the black toggle.

The output is two things built together: the padded image tensor, and a mask where your original pixels are 1 and the new margin is 0. Note the polarity - the margin is 0, the original content is 1 - which is the standard "what to keep" orientation. If you invert it you're telling the inpaint pass to replace your original image, which you basically never want.

Because the whole thing is done in tensor space, it works on batches and keeps your image data as tensors - no round-trip through the filesystem.

Inputs and outputs

  • image (IMAGE) - what you're padding.
  • margin_pct (INT, 0–100) - margin height as a percentage of the image's height. Default 10.
  • top (BOOLEAN) - margin on top (on) or bottom (off). Default bottom.
  • black (BOOLEAN) - black margin (on) or white (off). Default black.

Outputs:

  • OUTPUT_IMAGE (IMAGE) - the padded image.
  • MASK (MASK) - 1 where original content is, 0 in the margin.

Wire OUTPUT_IMAGE and MASK into a Set Latent Noisy Mask / inpaint setup (or ComfyUI's own InpaintModelConditioning) to outpaint the strip.

Installing it

Ships in ComfyUI Fictiverse Nodes. ComfyUI Manager → search "ComfyUI Fictiverse Nodes" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Fictiverse/ComfyUI_Fictiverse

No dependencies beyond torch (which ComfyUI needs anyway) and no model files. Apache 2.0.

Common issues

Pack-level: ModuleNotFoundError: No module named 'custom_nodes.ComfyUI_Fictiverse' on startup means the folder name isn't exactly ComfyUI_Fictiverse; rename and restart.

Node-specific, three things. First, it's top/bottom only - if you need left/right margins for a wide-shot outpaint, this isn't the node. Second, the margin color matters more than it seems: black is the safer fill for most outpainting because dark regions get treated as "unknown detail here," while white tends to read as bright fog and can pull the inpaint toward washed-out results. Third, the margin is calculated off height, not the image area, so on a wide image 10% can look small - bump margin_pct if the strip feels cramped. And remember the mask polarity: keep original=1, margin=0.

CategoryFictiverse/ImageProcessing

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
margin_pctINT100–100
topBOOLEANfalse
blackBOOLEANtrue

Outputs (2)

NameTypeDescription
OUTPUT_IMAGEIMAGE
MASKMASK