Nodes/Eden.art nodesuite/AspectPadImageForOutpainting
ComfyUI Node Runs on cloud

AspectPadImageForOutpainting

Fit any image to an SDXL canvas, correctly

By edenartlabΒ·Created 3 years agoΒ·Updated 6 months agoΒ· 119
AspectPadImageForOutpainting
  • image
  • IMAGE
  • LEFT
  • TOP
  • RIGHT
  • BOTTOM
β—„aspect_ratio16-9_landscape_1344x768β–Ί
β—„justificationcenterβ–Ί

Outpainting has one fiddly requirement that trips everyone: your input image almost never matches the aspect ratio you want to generate into, and the moment you stretch it to fit, your subject looks wrong and the model gets confused. AspectPadImageForOutpainting is Eden.art's polite answer - it resizes your image to fit inside one of the SDXL-native aspect ratios without distorting it, then pads the rest with empty canvas and hands you the exact padding numbers.

The elegant bit is that it doesn't do the outpaint itself. It's a calculator dressed as a node: it computes everything the stock ComfyUI "Pad Image For Outpainting" node needs, so you keep using the built-in tool but stop doing the mental math.

How it works

The node holds a map of the nine canonical SDXL aspect ratios, from 1-1_square_1024x1024 up to 21-9_landscape_1536x640 and the portrait equivalents. Given your image, it:

  1. Compares your image's aspect ratio to the target canvas.
  2. Resizes the image (bicubic) so it fits inside the canvas while preserving its own aspect ratio - one dimension reaches the canvas edge, the other falls short.
  3. Computes how much padding that leaves on each side: LEFT, TOP, RIGHT, BOTTOM.

That last part is why you get five outputs instead of one. Wire the padded IMAGE into the stock Pad Image For Outpainting node (or use the numbers yourself to place a crop), and the resize-plus-pad dance is done for you.

Inputs and outputs

  • image - what you're extending.
  • aspect_ratio - one of the nine presets. The default is 16-9_landscape_1344x768, which is SDXL's favorite widescreen canvas; pick whichever matches where you're going, not where you are.
  • justification - center (default), top-left, or bottom-right. Controls which way the existing image sits in the new canvas. Center is right for most outpainting; top-left is useful when you're deliberately extending only right/down.

Outputs: IMAGE (the resized, padded image at full canvas size) and the four INT padding values. The padding ints are the connective tissue - they tell the downstream outpaint step exactly which region is "real" image vs. empty canvas.

Why you'd use this over hand-rolled math

Because it's one click and it never produces a warped image. The classic failure mode people hit is stretching a square photo into a 16:9 canvas and watching the model happily outpaint an already-distorted face. This node sidesteps it, and the KB's outpainting essay backs the approach: masked/region generation still owns bit-identical untouched pixels, so a clean fit-and-pad is the correct foundation for an outpaint pass - you want the existing image to stay exactly as it was and only the padded region to generate. That's precisely the setup this node gives you.

Installing

It's in edenartlab/eden_comfy_pipelines (Eden.art nodesuite):

cd ComfyUI/custom_nodes
git clone https://github.com/edenartlab/eden_comfy_pipelines.git
cd eden_comfy_pipelines
pip install -r requirements.txt

Or ComfyUI Manager β†’ search "Eden". No models, no extra deps.

Gotchas

One thing to keep straight: the IMAGE output is resized, not just padded - a 512Γ—512 input becomes 1024Γ—1024 (if square), so your existing content is upscaled a little to meet the canvas. That's expected and fine for outpainting, but don't use this node when you want the source kept pixel-identical - it's a "fit the canvas" tool, not a "paste without touching" tool. Also, the pad values are what you'd feed to mask construction: the empty region is LEFT..RIGHT and TOP..BOTTOM of the canvas, which is exactly the region you want set as the inpaint mask.

CategoryEden 🌱

Inputs (3)

NameTypeDefaultDescription
imageIMAGEβ€”
aspect_ratioCOMBO16-9_landscape_1344x7689 options: 1-1_square_1024x1024, 4-3_landscape_1152x896, 3-2_landscape_1216x832, 16-9_landscape_1344x768, 21-9_landscape_1536x640, 3-4_portrait_896x1152, +3
justificationCOMBOcenter3 options: top-left, center, bottom-right

Outputs (5)

NameTypeDescription
IMAGEIMAGEβ€”
LEFTINTβ€”
TOPINTβ€”
RIGHTINTβ€”
BOTTOMINTβ€”