Nodes/ComfyUI-MaxedOut/Pad Image for Outpainting MXD
ComfyUI Node

Pad Image for Outpainting MXD

Grow your canvas for outpainting — with the mask built in

By Maxed-Out-99·Created about a year ago·Updated 21 days ago· 9
Pad Image for Outpainting MXD
  • image
  • IMAGE
  • MASK
left0
top0
right0
bottom0
round_to16

Outpainting is just inpainting with extra steps: you enlarge the canvas, then ask the model to fill the empty space around your original image. The fiddly part is the setup - you need the image padded out, and you need a mask that says "everything except my original content is new." Pad Image for Outpainting MXD does both in one node: it pads your image with neutral grey, rounds the result to a friendly resolution, and hands you the matching MASK so the empty border is exactly what gets regenerated.

Why the padding details matter

Two things trip people up when they hand-build this. First, models like clean multiples - Flux, SDXL, and friends all behave better when the canvas lands on a nice number, which is why the node has a round_to dropdown (None / 2 / 8 / 16 / 32 / 64, default 16). Second, a correct mask: if the mask includes your original pixels, the model will rewrite your existing content instead of just filling the border. This node sets the padded area to 1 in the mask and your original region to 0, so you're always outpaining the right half.

How it works

Under the hood it's careful arithmetic, not magic:

  1. It adds your requested padding (left / top / right / bottom) to each axis.
  2. It rounds the final size to your chosen multiple, adjusting the padding - and if rounding would overshoot, it crops the outer frame by a hair so the math stays consistent. (The step: 2 on the inputs is a hint that even sizes are the plan.)
  3. It fills the new canvas with 0.5 grey (mid-neutral, the standard inpaint starting value) and stamps your original image into place.
  4. It returns the padded IMAGE plus a MASK where the border is white and your original is black.

The mask is the star. Wire MASK into an inpaint-mask input, and your padding becomes a self-contained outpaint region with zero hand-painting of masks.

Inputs that matter

  • left / top / right / bottom - how much to grow each side, in pixels. Zero means "don't grow that side."
  • round_to - the multiple to round the final canvas to. 16 is the safe default; 64 is what you'd reach for if you're feeding a Flux-style model that likes bigger blocks.
  • Outputs: IMAGE (the padded canvas) and MASK (the border region).

Install

cd ComfyUI/custom_nodes
git clone https://github.com/Maxed-Out-99/ComfyUI-MaxedOut.git

Restart, or ComfyUI Manager → search "Maxed Out" → install. No extra dependencies - pure tensor work.

Troubleshooting

  • "Rounding removed the full image on one axis" - you asked for huge padding relative to a tiny image and the rounding math ate it. Increase the original or reduce the padding.
  • The outpainted border looks smeared, not regenerated - your mask isn't reaching the inpaint node, or you're sampling at denoise 1.0 instead of 0.5–0.8. Padding the canvas is only half the job; the other half is a proper inpaint sample over the masked area.
  • Resolution jumps - if you outpaint in one huge step the model invents more than it can handle. Pad in stages (a few hundred pixels at a time, re-inpaint, repeat) for the good results - this node makes staging trivial since each stage is just another pad+fill.

For the "expand my image past its edges" job, this is the rare node that gives you both halves of the setup in one call.

Categoryimage/transform

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
leftINT00–16384
topINT00–16384
rightINT00–16384
bottomINT00–16384
round_toCOMBO166 options: None, 2, 8, 16, 32, 64

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK