Padding Calculator
Padding Math That Never Returns a Fractional Pixel
- new_width
- new_height
- pad_pixels_width
- pad_pixels_height
- info
Padding Calculator is the rare ComfyUI node that doesn't touch an image at all - it does math. Feed it your width, height, and a padding percentage, and it hands back the new dimensions plus the exact per-side pixel padding, rounded to whole pixels. That's it. It's a utility node, and it's honest about being one.
So why does it exist? Because "add 10% padding" sounds trivial until you realize the result needs to be a whole number of pixels, split evenly on both sides, and if you're feeding the result into a crop, resize, or pad node that demands integer inputs, a fractional padding value is a silent bug waiting to happen. This node does the rounding before anything else touches the numbers, and it tells you exactly what it decided.
How it works
It computes the raw padding per side (width × percentage / 100), rounds it according to rounding_mode - round (nearest, default), floor, or ceil - and then reports the new full dimensions. Padding is added on both sides, so the new width is width + 2 × pad_pixels.
Inputs and outputs
All inputs are simple numbers:
- width, height - your original dimensions.
- pad_percentage (0-100) - how much padding, per side.
- rounding_mode -
roundis the sane default; useceilif you must never fall below the requested padding,floorif you must never exceed it.
Five outputs, and they're designed to be wired straight into downstream nodes:
- new_width, new_height - dimensions after padding.
- pad_pixels_width, pad_pixels_height - the per-side values, for when a crop node wants padding directly.
- info - a string summary (input, requested %, rounding, output) for logging or display.
Installing it
It's part of the TextureAlchemy pack. ComfyUI Manager (search "TextureAlchemy"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy
Restart, and it lives under Texture Alchemist → Texture. No dependencies beyond what ComfyUI already has.
When you'd reach for it
Honestly, this is a niche node and it knows it. You'd use it in workflows that need to pad a texture before processing - adding a border to an image before seamless tiling, reserving room for a mask, or prepping an image for a node that requires even dimensions. It pairs naturally with the pack's own padding/pad-based tools. If you're doing any of that repeatedly, having the percentage→pixels conversion as a node (instead of a calculator app next to your keyboard) keeps the workflow self-documenting. If you never pad textures, you'll never need it - skip it with a clear conscience.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 10241–16384 | Original image width in pixels |
| height | INT | 10241–16384 | Original image height in pixels |
| pad_percentage | FLOAT | 10.00–100 | Padding percentage (will be rounded to whole pixels) |
| rounding_mode | COMBO | round | How to round fractional pixels: round (nearest), floor (down), ceil (up) |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| new_width | INT | — |
| new_height | INT | — |
| pad_pixels_width | INT | — |
| pad_pixels_height | INT | — |
| info | STRING | — |