Nodes/ComfyUI/Pad Image for Outpainting
ComfyUI Node Runs on cloud

Pad Image for Outpainting

ImagePadForOutpaint pads the canvas and hands you the mask

By Comfy-Org·Created 4 years ago·Updated about 5 hours ago· 129,964
Pad Image for Outpainting
  • image
  • IMAGE
  • MASK
left0
top0
right0
bottom0
feathering40

If you've ever wanted to extend an image past its own edge - add sky above a portrait, or the rest of a table that got cut off - this is the node people mean when they say "the outpainting node." It doesn't do any generating. It sets the table: it grows the canvas and hands you the exact mask that tells the sampler where to invent and where to leave the original alone.

This is the oldest member of the image/transform family and it's been in ComfyUI core since the early days - SeargeSDXL workflows were already dragging it around back in 2023. Nothing to install; it's in nodes.py.

How it works

Give it an image and how many pixels to add on each side. It places the original on a bigger canvas and fills the new border with mid-gray (0.5, not black) - that neutral fill matters, because the model sees it as "nothing decided here yet." Then it builds a mask where the padding is 1 and the original's interior is 0.

Here's the convention that trips everyone up, and it's worth getting right: in ComfyUI's sampler, mask value 1 means "regenerate this," and 0 means "keep the original latent." So ImagePadForOutpaint marks the padding as the thing to invent and the original as the thing to preserve - and the feathering ramp along the original's edge turns that binary into a smooth quadratic blend, so the sampler is free to ease the new content into the old instead of slamming into a hard seam.

That feathering is the whole trick. A hard 0/1 edge between "keep" and "invent" shows up as a visible seam after sampling. The default 40px feather is what makes the join disappear. Crank it down for a sharp boundary, up when the seam fights you.

The inputs that matter

  • left / top / right / bottom - pixels to add on each side. They step by 8 in the UI, which isn't an accident: you want the final canvas to stay latent-friendly (multiples of 8, or 64 for video VAEs) or the encode step will silently crop your canvas.
  • feathering - edge blend width, default 40. This is the dial you'll actually tune.

Outputs are the part beginners miss: IMAGE (the padded canvas) and MASK (the regenerate/keep map). You need both.

Wiring it up

The classic graph is three nodes long:

LoadImage → ImagePadForOutpaint → VAEEncodeForInpaint → KSampler (denoise ~1.0) → VAEDecode
                                    ↑ mask goes in here

Feed the padded image and its mask into VAEEncodeForInpaint (or encode first and SetLatentNoiseMask), then sample at high denoise. The mask is what stops the sampler from destroying the part you're keeping. The single most common failure - your whole image comes back regenerated, original gone - is forgetting to wire that mask, which leaves the sampler with no keep-region and no reason to spare the original.

When to reach for it (and when not to)

Outpainting got a new lease in 2025-2026 because instruction models like Flux Klein can extend an image if you just pad it and tell them to replace the padding - no mask needed. That's a great two-node trick for quick canvas grows, and it's the better answer when nothing in the original has to survive byte-for-byte. But masked outpainting still owns the case where the original must not drift: one pass with this node, and only the extension was ever denoised. Use this when the original pixels are the product.

Troubleshooting

  • Visible seam: bump feathering up (60-100px). The feather band is your blend budget, and 40px is often not enough for big canvas grows.
  • Original pixels changed: the mask didn't reach the sampler. Check the mask wire.
  • Black or clipped edge after encode: your padded size isn't a multiple of the VAE's compression factor. Make left/right/top/bottom sums land on multiples of 8 (64 for video).
  • Extension looks pasted-on: extend in passes - pad a little, sample, pad more - instead of one huge jump, and let denoise sit high (0.8-1.0) since the padding is all new content.
Categoryimage/transform

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
leftINT00–16384
topINT00–16384
rightINT00–16384
bottomINT00–16384
featheringINT400–16384

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK