AGSoft Img Pad
Pad an image and get the outpainting mask for free
- image
- IMAGE
- MASK
- width
- height
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.constantfills with a solidbackground_color;edgereplicates the border pixels (good for a subtle base that blends);reflectandsymmetricmirror 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.
Inputs (9)
| 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=оригинальное изображение |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| width | INT | — |
| height | INT | — |