Aspect Pad For Outpainting
Stop doing padding math by hand
- image
- IMAGE
- LEFT
- TOP
- RIGHT
- BOTTOM
Aspect Pad For Outpainting exists to kill the fiddliest part of an outpaint workflow: working out how many pixels of padding you need on each side to land on a clean target aspect ratio. Outpainting, as the KB's inpainting essay puts it, is the piece instruction-editing models took cleanly - but when you're doing it the old-school way with ComfyUI's built-in Pad Image For Outpainting node, you have to hand-compute left/right/top/bottom values that match a model's native resolution. That math is boring and error-prone. This node does it.
How it works
You feed it an image, pick a target aspect_ratio from nine presets (SDXL and SD1.5 sizes: 1:1 at 1024², 16:9 at 1344×768, 9:21 portrait at 640×1536, and everything between), and choose a justification - top-left, center, or bottom-right for where your image sits on the canvas.
The source is refreshingly simple. It compares your image's aspect ratio to the canvas, scales the image up (bicubic) until one dimension matches the canvas while preserving the ratio, then computes the leftover space on each side. Center justification splits it evenly; top-left shoves everything into the corner. The output IMAGE is your resized image, and LEFT, TOP, RIGHT, BOTTOM are the exact integers the built-in Pad Image For Outpainting node wants.
The wiring pattern
The intended graph is: this node → Pad Image For Outpainting → sampler. Plug IMAGE, LEFT, TOP, RIGHT, BOTTOM straight into the pad node's corresponding inputs, and your image gets padded out to a clean native-res canvas with no seams and no math on your part. The two nodes are designed to be adjacent; the DRMBT naming is the pack's own prefix, but this one explicitly builds on ComfyUI's stock node rather than replacing it.
Two things to know before you queue it:
- It upscales your image to fit. If your source is smaller than the canvas, the node resizes it up rather than leaving it pixel-sized - which is what you want for outpainting, but means your source resolution gets stretched first. Feed it the highest-res version of your image you have.
- The aspect presets assume landscape/portrait semantics.
16-9_landscape_1344x768means width×height 1344×768; pick the matching orientation or your image gets letterboxed the wrong way. Minor, but it's the most common first-run mistake.
Install
It ships in drmbt/comfyui-dreambait-nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/drmbt/comfyui-dreambait-nodes
then restart ComfyUI, or grab it via ComfyUI Manager ("comfyui-dreambait-nodes"). The pack installs its full dependency set regardless, so expect the heavy pip install even though this node only needs torch. For outpainting specifically, it's the difference between a 30-second manual calculation every time you change target aspect and a dropdown you never think about again.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| aspect_ratio | COMBO | 16-9_landscape_1344x768 | 9 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 |
| justification | COMBO | center | 3 options: top-left, center, bottom-right |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| LEFT | INT | — |
| TOP | INT | — |
| RIGHT | INT | — |
| BOTTOM | INT | — |