Nodes/ComfyUI-TextureAlchemy/Padding Calculator
ComfyUI Node

Padding Calculator

Padding Math That Never Returns a Fractional Pixel

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Padding Calculator
    • new_width
    • new_height
    • pad_pixels_width
    • pad_pixels_height
    • info
    width1024
    height1024
    pad_percentage10.0
    rounding_moderound

    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 - round is the sane default; use ceil if you must never fall below the requested padding, floor if 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.

    CategoryTexture Alchemist/Texture

    Inputs (4)

    NameTypeDefaultDescription
    widthINT10241–16384Original image width in pixels
    heightINT10241–16384Original image height in pixels
    pad_percentageFLOAT10.00–100Padding percentage (will be rounded to whole pixels)
    rounding_modeCOMBOroundHow to round fractional pixels: round (nearest), floor (down), ceil (up)

    Outputs (5)

    NameTypeDescription
    new_widthINT
    new_heightINT
    pad_pixels_widthINT
    pad_pixels_heightINT
    infoSTRING