Nodes/comfyui-AGSoft/AGSoft Img Pad Adv
ComfyUI Node

AGSoft Img Pad Adv

Padding with a target resolution, not just 'add 64 pixels'

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

Plain AGSoft Img Pad answers the question "how many pixels do I add on each side?" This one answers the more useful question: "what resolution do I want the canvas to end up at?" Img Pad Adv is the same idea - add canvas, generate the outpaint mask - with the addition of target dimensions and aspect-ratio control. If you find yourself doing the math to figure out how much padding turns a 1024×1024 into a 1344×768 canvas, this node is the calculator you didn't know you needed.

It inherits everything from the base pad node: pad_left/top/right/bottom, pad_mode (constant/edge/reflect/symmetric), background_color, feathering, and invert_mask. The mask still comes out marking the padding area by default (1 = padding, 0 = original), and the feathering default of 40 is still your seam insurance. What's new is the second half of the node.

The advanced half

  • target_width / target_height - the dimensions you want the final padded canvas to be. Set both to 0 (the default) and this behaves like the basic node, adding only your explicit padding. Set one or both and the result is scaled up or down to land there.
  • keep_proportions - if the target aspect ratio doesn't match the padded image's, this keeps the image undistorted and leaves the difference as extra padding. Turn it off and it'll stretch to hit the exact box.
  • resize_position - where the (possibly resized) image sits inside the target canvas: center, top-left, top-right, bottom-left, bottom-right. Center is the default and usually right; the corners exist for when you're building a specific layout.

The workflow this unlocks: type in the resolution your model or video VAE actually wants, and the node both pads and resizes to hit it, handing you a correctly sized mask alongside. For outpainting into a specific aspect ratio - say, extending a square to 16:9 - that's the entire setup in one node.

Outputs

IMAGE, MASK, width, height. Wire the mask to your sampler, the image to a VAE encode, and the dimensions to an Empty Latent so everything lines up.

Installation

Part of comfyui-AGSoft:

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

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

Where people get burned

The trap with target dimensions is forgetting that keep_proportions is doing real work. If you set a target that has a different aspect ratio than your padded image and keep proportions on, you'll get extra padding you didn't explicitly ask for - which is usually fine, but it changes your mask coverage, so check the output size before you sample. The other habit worth building: pad to a resolution your model's multiple tolerates. Set your target_width/target_height to numbers divisible by 8 (or 64 for FLUX/video), because the target fields don't auto-snap. When in doubt, start from the base node and only reach for Adv when you actually need the resolution math.

CategoryAGSoft/Image

Inputs (13)

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=оригинальное изображение
target_widthoptINT00–8192Target width after padding (0 = disable scaling) Целевая ширина после паддинга (0 = отключить масштабирование)
target_heightoptINT00–8192Target height after padding (0 = disable scaling) Целевая высота после паддинга (0 = отключить масштабирование)
keep_proportionsoptBOOLEANtrueMaintain original aspect ratio when scaling Сохранять оригинальные пропорции при масштабировании
resize_positionoptCOMBOcenterPosition of resized image within target dimensions Позиция масштабированного изображения внутри целевых размеров

Outputs (4)

NameTypeDescription
IMAGEIMAGE
MASKMASK
widthINT
heightINT