Nodes/ComfyUI-YCNodes/Yc Image Smart Pad
ComfyUI Node

Yc Image Smart Pad

Pad a canvas and get a mask of the new border — your outpainting starts here

By yichengup·Created 2 years ago·Updated 4 months ago· 48
Yc Image Smart Pad
  • image
  • image
  • mask
left100
top100
right100
bottom100
pad_modeedge
fill_color#fffddd
invert_maskfalse

Pad an image by a set number of pixels on each side and get back two things: the padded image and a mask that marks exactly which pixels are new. That second output is what makes this an outpainting tool rather than a boring image-shaper. You pad out the canvas, run inpainting with the mask telling the model "only touch the border", and the original content stays bit-identical.

What it's actually for

Classic outpainting flow: you have a 512×512 shot and you want a 768×512 scene - more sky, more room, whatever the frame cut off. Pad first, then generate only into the new area. Without a mask telling the model where the new pixels are, the sampler happily re-paints your whole image and your characters drift. The mask output here is precisely the "inpaint here, not there" map, which is exactly the bit-identical-mask guarantee the inpainting docs say masked regeneration still owns.

How it works

Each image in the batch gets padded by left, top, right, bottom pixels. How the border is filled depends on pad_mode:

  • edge (default) - copy the outermost pixels, Photoshop-style content-awarish border
  • reflect / symmetric - mirror the image, useful when you'll inpaint and want plausible continuity
  • wrap - tile it, mostly for textures
  • constant - solid color from fill_color (hex, default #fffddd)

The mask is drawn at the padded size with the original region white and the added border black; flip invert_mask and the border becomes white instead. Some inpaint setups want the region-to-fill as the white part, so keep that toggle in mind.

Inputs and outputs

The ones you actually touch:

  • left / top / right / bottom - pixels to add (default 100 each, up to 1000)
  • pad_mode - how the new border is generated
  • fill_color - used only when pad_mode = constant

Outputs are the padded image and the mask. Feed both into a masked-inpaint sampler, or pair the mask with YCMaskBlur (same pack) to soften the seam before sampling - hard mask edges are the #1 cause of visible outpainting borders.

Install

Same pack, same story: ComfyUI Manager → search "ComfyUI-YCNodes" → install, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/yichengup/ComfyUI-YCNodes

Then restart. Dependencies are torch, numpy, pillow, opencv-python, scipy - no model files to fetch. The non-constant pad modes run through OpenCV's copyMakeBorder, so if you see the whole image module missing from your menu, it's almost always opencv-python that failed to load; the console will show a ❌ Failed to load node line.

Where people get burned

  • Forgetting the mask is the point. Pad without routing the mask into the sampler and you're just making a bigger image with a smeared border. The mask is not optional - it's the whole trick.
  • Hard edges. Generate straight from this node's mask and you'll see a seam. Blur the mask first.
  • RGBA quirks. The constant mode handles alpha by filling the new alpha as opaque, but if you're padding transparent images for compositing, check the result rather than assuming.

It's a small node, but it slots directly into the outpainting loop and saves you from hand-drawing region masks every time you want a wider frame.

CategoryYCNode/Image

Inputs (8)

NameTypeDefaultDescription
imageIMAGE
leftINT1000–1000
topINT1000–1000
rightINT1000–1000
bottomINT1000–1000
pad_modeCOMBOedge5 options: edge, reflect, symmetric, wrap, constant
fill_colorSTRING#fffddd
invert_maskBOOLEANfalse

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK