Outpaint Padding Compute
Outpaint Padding Compute is arithmetic, not magic — that's the point
- image
- outpaint_config
- left
- top
- right
- bottom
What it's for
Outpainting always starts with the same boring step: put the original on a bigger canvas. Where exactly, and how much bigger, is four numbers. Most workflows make you do that by hand in the padding node's widgets, which means every time you change the source aspect ratio you re-guess and the seam moves.
This node extracts that arithmetic. You hand it an image and an Outpaint Config bundle; it hands back four integers. Nothing else. It doesn't generate pixels, doesn't feather a mask, doesn't call a model - it's a calculator with a ComfyUI face. That's genuinely useful, because it means the whole workflow's expansion policy lives in one configurable place instead of in the padding node's widgets.
How it works
Two modes, and they don't mix:
Percent mode takes horizontal_percent and vertical_percent as the total expansion relative to the source width and height, then splits each one according to gravity. Center gravity halves it (rounding the left/top side down and giving the remainder to the right/bottom). left or top left or bottom left puts all the horizontal expansion on the right; right and friends put it all on the left. The pixel count is round(width * horizontal_percent / 100).
Pixels mode ignores gravity entirely and uses left_px, right_px, top_px, bottom_px literally.
Either way, the last step adds one pixel to right and/or bottom if that's what it takes to make the final canvas dimensions even. That's a small thing that saves you from a downstream node that quietly rounds.
Outputs are left, top, right, bottom, in that order, as INTs - wire them into whatever your canvas-expansion node of choice is (ImagePadForOutpaint, KJ's pad nodes, anything with four margin widgets). If you're also padding a mask, feed the same four numbers to the mask pad so the grids stay aligned; nothing here will do it for you.
Why the split is worth it
Because outpainting itself has moved. The masked route - pad the canvas, mask the new border, denoise it back in - is still correct when the original pixels must survive byte-for-byte, and it's the only option that guarantees that. The practical rule for its seams is generous mask overlap, covering 20–30% of the original edge, plus adequate blur.
But the 2026 shortcut needs no mask at all: pad each side with a flat colour and ask an instruction editor to replace it. "Pad with 200px red, then remove the red padding and show what's behind" is a two-node trick that works on any instruction model, and Klein is reportedly good at it. This node is happy either way - it's just the geometry. Whether the padding becomes black canvas, red canvas or an edge extension is your call, and if you'd rather the suite decide, Smart Photo Prepare reads padding_fill (Edge extension, Black, White) off the crop bundle.
Inputs and outputs, plainly
Required: image (IMAGE) and outpaint_config (PORTRAIT_OUTPAINT_CONFIG_V2). No optional inputs, no widgets of its own - every setting comes from the config node. That's the whole interface:
Load Image ──────────┐
├─> Outpaint Padding Compute ─> left/top/right/bottom ─> pad node
Outpaint Config ─────┘
The config bundle comes from Outpaint Config, which also carries outpaint_prompt for the editor. Read that out with Outpaint Prompt from Config if your editor node wants a plain STRING.
Install
Same pack as everything else. ComfyUI Manager → search PortraitUtils (heyburns), or:
cd ComfyUI/custom_nodes
git clone https://github.com/heyburns/PortraitUtils
/path/to/ComfyUI/venv/bin/python -m pip install -r PortraitUtils/requirements.txt
Restart the server afterwards; a browser refresh won't load new Python classes.
Where people get burned
Two things. First, gravity in Percent mode reads from the image's position, not from the direction you're adding - left keeps the source at the left and adds everything on the right, which is the opposite of what half of us type the first time. Second, the even-canvas nudge is not an editor-native resolution guarantee: if you're padding for Qwen 2.1 you want dimensions aligned to 32, and that's Smart Photo Prepare's job, not this node's. There's no outpaint_config widget here either, so the bundle must arrive as a wire - connect it, don't go looking for a dropdown.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| outpaint_config | PORTRAIT_OUTPAINT_CONFIG_V2 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| left | INT | — |
| top | INT | — |
| right | INT | — |
| bottom | INT | — |