Nodes/comfyui-AGSoft/AGSoft Img Pad
ComfyUI Node

AGSoft Img Pad

Pad an image and get the outpainting mask for free

By Art-xmaster·Created 12 months ago·Updated a day ago· 23
AGSoft Img Pad
  • image
  • IMAGE
  • MASK
  • width
  • height
pad_left0
pad_top0
pad_right0
pad_bottom0
pad_modeconstant
background_colorgray
feathering40
invert_maskfalse

If you want to outpaint - extend a portrait upward, widen a landscape, give a subject more headroom - the recipe is: add blank canvas around the image, mask the new area, and let the sampler fill it. AGSoft Img Pad is the node that does the first two steps in one shot. It adds padding on any side and, crucially, hands you a mask covering exactly the padding you just added.

That mask is the whole point. Outpainting only works if the model knows what to regenerate, and hand-drawing a border mask is tedious and error-prone. Here you get image, mask, width, and height out the other side, aligned by construction - the same "keep image and mask in sync" philosophy that runs through this whole pack.

How it works

You give it an image and set how many pixels to add on each side: pad_left, pad_top, pad_right, pad_bottom. By default the mask marks the padding as the area to regenerate (1 = padding, 0 = original image), which is exactly what a KSampler's mask input wants.

Beyond the pixel counts, three settings shape the result:

  • pad_mode - how the padding is filled. constant fills with a solid background_color; edge replicates the border pixels (good for a subtle base that blends); reflect and symmetric mirror the image across the edge. Constant is the standard outpaint starting point.
  • feathering - the soft transition radius on the mask edges (default 40). This is the difference between a visible seam and a smooth blend. Turn it to 0 and you get a hard edge, which is rarely what you want.
  • invert_mask - flips the mask so it marks the original image instead. Handy if the node you're feeding expects the opposite polarity.

Outputs are IMAGE, MASK, width, height. All four matter: the mask goes to your sampler, the dimensions go to an Empty Latent so the latent matches the padded canvas, and the image is what you VAE-encode.

Installation

From the comfyui-AGSoft pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Art-xmaster/comfyui-AGSoft.git
# restart ComfyUI

Or via ComfyUI Manager (search "comfyui-AGSoft"). numpy + opencv-python, no model downloads.

Where people get burned

The classic mistake is padding only some sides and forgetting that the model's VAE wants canvas dimensions it can handle - a padded image that's now 1399×1024 will choke most latents. This node doesn't auto-round, so pair the width/height outputs with a divisible_by resize or just choose padding amounts that land on sampler-friendly numbers. Second classic: feathering set to zero and then wondering why the outpaint looks patched on. Leave the default feathering alone unless you know why you're changing it. And if you need the fancier version - target dimensions, aspect-ratio preservation, and placement control - the pack's AGSoft Img Pad Adv is this node with the training wheels off.

CategoryAGSoft/Image

Inputs (9)

NameTypeDefaultDescription
imageIMAGEInput image to add padding to Входное изображение, к которому добавляется паддинг
pad_leftoptINT00–8192Pixels to add on the left side Пикселей для добавления слева
pad_topoptINT00–8192Pixels to add on the top side Пикселей для добавления сверху
pad_rightoptINT00–8192Pixels to add on the right side Пикселей для добавления справа
pad_bottomoptINT00–8192Pixels to add on the bottom side Пикселей для добавления снизу
pad_modeoptCOMBOconstantPadding mode: constant - fill with background color edge - replicate edge pixels reflect - reflect around edge symmetric - symmetric reflection Режим паддинга: constant - заполнение фоновым цветом edge - копирование пикселей с краев reflect - отражение относительно края symmetric - симметричное отражение
background_coloroptCOMBOgrayBackground color for constant padding mode Фоновый цвет для режима constant
featheringoptINT400–512Feathering radius for mask edges (soft transition) Радиус растушевки краев маски (плавный переход)
invert_maskoptBOOLEANfalseInvert mask: 0=padding area, 1=original image area Инвертировать маску: 0=область паддинга, 1=оригинальное изображение

Outputs (4)

NameTypeDescription
IMAGEIMAGE
MASKMASK
widthINT
heightINT