Nodes/KJNodes for ComfyUI/Image Pad For Outpaint Target Size
ComfyUI Node Runs on cloud

Image Pad For Outpaint Target Size

Pad to a size for outpainting, no arithmetic

By kijai·Created 3 years ago·Updated a day ago· 3,011
Image Pad For Outpaint Target Size
  • image
  • mask
  • IMAGE
  • MASK
target_width0
target_height0
feathering0
upscale_method

Outpainting - extending an image beyond its original borders - starts with the least glamorous step: adding blank canvas around the picture and a mask marking the new area, so the sampler knows what to fill. The native ImagePadForOutpaint node makes you specify padding as explicit left/right/top/bottom pixel amounts. This one flips it: you tell it the final size you want, and it figures out the padding for you. Much friendlier when you're aiming at a specific aspect ratio or resolution.

Why the "target size" framing is nicer

Say you've got a 512x768 portrait and you want a 1024x1024 square to outpaint into. With the native node you'd sit there doing subtraction - how much on each side to center it - and it's easy to get off-by-a-bit and end up with the subject nudged off-center. With this node you just type target_width 1024, target_height 1024, and it pads the image out to that size and hands you the matching mask in one shot. The framing matches how you actually think about outpainting: "I want this to become 16:9," not "add 213 pixels left and 213 right."

It produces both the padded image and the mask together, which is exactly the pair an inpainting/outpainting sampler pass needs - the image with room to grow, and the mask telling the model which part is new.

The inputs and outputs that matter

  • image - the picture to extend.
  • target_width / target_height - the final canvas size. The original is placed inside this and the surrounding area becomes the outpaint region.
  • feathering (default 0) - softens the boundary between original and new area over this many pixels. A little feathering helps the fill blend instead of showing a hard seam; too much eats into the original. A modest value is the usual pick.
  • upscale_method - the resampling filter used when the source has to be scaled to fit the target (lanczos, bicubic, etc.).
  • mask (optional) - pass an existing mask through if you're combining this with other masked regions.

Two outputs: the padded IMAGE and the MASK marking the new region. Wire both into your outpainting sampler setup - image to the latent-encode path, mask to the inpaint conditioning.

How to install it

It's part of kijai's KJNodes pack.

  • ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r ComfyUI-KJNodes/requirements.txt, restart.

No models or dependencies - it's a canvas/mask operation.

Common issues & troubleshooting

Visible seam where the new area meets the original. Bump feathering up a bit so the transition blends, and make sure the model doing the fill is actually good at outpainting - Flux, for instance, is notably strong at extending environments and people cleanly, where older SD1.5 checkpoints can smear at the join.

Target smaller than the source. If target_width/target_height is smaller than the image in a dimension, there's nothing to pad - outpainting needs the target to be larger. Set the target bigger than the original in whatever direction you want to extend.

The fill ignores the original content near the edge. That's usually a denoise/mask issue in the sampler pass, not the padding - with feathering at 0 and a hard mask, the model has no gradient to blend into. A few pixels of feather plus a sampler pass that respects the unmasked region fixes it.

Odd sizes. Target dimensions step in multiples of 8 (and models generally prefer multiples of 8 or 64). Weird sizes can produce faint artifacts at the boundary; round to a clean multiple.

Categoryimage

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
target_widthINT00–16384
target_heightINT00–16384
featheringINT00–16384
upscale_methodCOMBO5 options: nearest-exact, bilinear, area, bicubic, lanczos
maskoptMASK

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK