Compute Padding
A tiny math node that tells you how much padding to add — and nothing else
- left
- right
- top
- bottom
Let's set expectations right away: this node does not pad anything. It computes the four padding amounts - left, right, top, bottom - you'd need to stretch one image size up to a target canvas, and hands them to you as integers. That's the entire job. If you were hoping for a padded image, you want ComfyUI's built-in padding node; this one is the calculator that feeds it.
So why does it exist? This pack's compositing nodes (Move In_Or_Out, Replace Img_or_Vid_Bg, and friends) all care about exact canvas sizes, and the pack is built around dynamic, size-flexible workflows where images arrive at whatever resolution. When you're wiring sizes around the graph, sometimes you want the numbers, not the padded image - to plug into an offset, a pad node, or another node that needs explicit dimensions. That's this node's lane.
The math is plain arithmetic, easy to read in the source: if centering is on, padding is split evenly between both sides (left = right, or top = bottom). If not, the leftPadding / topPadding values you supply are used as the fixed side, and the opposite side absorbs whatever's left to hit the target - with overflow handled by borrowing back from the fixed side and everything clamped at zero. Feed it a source bigger than the target and you get all zeros.
Inputs that matter
- width / height - your source image size (defaults 512×512).
- targetWidth / targetHeight - the canvas you want to reach (defaults 768×768).
- centralizeHorizontal - on by default. Splits horizontal padding evenly.
- centralizeVertical - off by default. This asymmetric pair is the one gotcha: out of the box you get a canvas centered horizontally but pinned to the top vertically. Flip
centralizeVerticalon if you want it centered both ways. - leftPadding / topPadding - only consulted when centering is off for that axis.
Outputs are four INTs: left, right, top, bottom. Feed them into whatever consumes padding amounts.
Installing it
Part of the ComfyUI-Animation_Nodes_and_Workflows pack from Isi-dev. Install once, get all the nodes:
- ComfyUI Manager → search
ComfyUI-Animation_Nodes_and_Workflows→ install, restart. - Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Isi-dev/ComfyUI-Animation_Nodes_and_Workflows
cd ComfyUI-Animation_Nodes_and_Workflows
pip install -r requirements.txt
Note the pack's requirements list mediapipe, which is genuinely heavy - but it's only needed for the pack's LivePortrait face node. This one is pure Python integer math; it runs on a toaster. No models, no downloads.
Honestly, this is the node you reach for when you're building a workflow where sizes come from elsewhere - an image loader, a latent size node - and you don't want to hardcode padding. If you're just padding one static image, skip it and use the core pad node. But if your canvas is dynamic, it's the difference between manual numbers and numbers that recompute themselves. Small, unglamorous, does one thing.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 51232–18446744073709550000 | — |
| height | INT | 51232–18446744073709550000 | — |
| targetWidth | INT | 76832–18446744073709550000 | — |
| targetHeight | INT | 76832–18446744073709550000 | — |
| leftPadding | INT | 00–18446744073709550000 | — |
| topPadding | INT | 00–18446744073709550000 | — |
| centralizeHorizontal | BOOLEAN | true | — |
| centralizeVertical | BOOLEAN | false | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| left | INT | — |
| right | INT | — |
| top | INT | — |
| bottom | INT | — |