AGSoft Img Pad Adv
Padding with a target resolution, not just 'add 64 pixels'
- image
- IMAGE
- MASK
- width
- height
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.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image to add padding to Входное изображение, к которому добавляется паддинг | |
| pad_leftopt | INT | 00–8192 | Pixels to add on the left side Пикселей для добавления слева |
| pad_topopt | INT | 00–8192 | Pixels to add on the top side Пикселей для добавления сверху |
| pad_rightopt | INT | 00–8192 | Pixels to add on the right side Пикселей для добавления справа |
| pad_bottomopt | INT | 00–8192 | Pixels to add on the bottom side Пикселей для добавления снизу |
| pad_modeopt | COMBO | constant | Padding mode: constant - fill with background color edge - replicate edge pixels reflect - reflect around edge symmetric - symmetric reflection Режим паддинга: constant - заполнение фоновым цветом edge - копирование пикселей с краев reflect - отражение относительно края symmetric - симметричное отражение |
| background_coloropt | COMBO | gray | Background color for constant padding mode Фоновый цвет для режима constant |
| featheringopt | INT | 400–512 | Feathering radius for mask edges (soft transition) Радиус растушевки краев маски (плавный переход) |
| invert_maskopt | BOOLEAN | false | Invert mask: 0=padding area, 1=original image area Инвертировать маску: 0=область паддинга, 1=оригинальное изображение |
| target_widthopt | INT | 00–8192 | Target width after padding (0 = disable scaling) Целевая ширина после паддинга (0 = отключить масштабирование) |
| target_heightopt | INT | 00–8192 | Target height after padding (0 = disable scaling) Целевая высота после паддинга (0 = отключить масштабирование) |
| keep_proportionsopt | BOOLEAN | true | Maintain original aspect ratio when scaling Сохранять оригинальные пропорции при масштабировании |
| resize_positionopt | COMBO | center | Position of resized image within target dimensions Позиция масштабированного изображения внутри целевых размеров |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| width | INT | — |
| height | INT | — |