Nodes/ComfyLab Pack/Resolution to Dimensions (lab)
ComfyUI Node

Resolution to Dimensions (lab)

Turn '1024x1024' into real width and height numbers

By bugltd·Created 2 years ago·Updated about a year ago· 11
Resolution to Dimensions (lab)
    • width
    • height
    resolution1024x1024
    scale_factor1.0

    ComfyUI's latent and image nodes want width and height as separate numbers, but humans think in strings like 1024x1024. Resolution to Dimensions (lab) is the tiny bridge between those two worlds: you type a resolution as text, and it hands you two clean INTs - optionally scaled. It's one of those nodes you don't think about until you're wiring a resolution through a variable, and then it saves you from arithmetic you were definitely going to get wrong.

    How it works

    The resolution field is parsed with a strict pattern: one or more digits, an x, another run of digits, with optional spaces (1024x1024, 1024 x 1024 both fine). Then each dimension is multiplied by scale_factor and truncated to an integer. If the string doesn't match the pattern at all, the node raises an error and goes red - it doesn't guess, it doesn't warn, it fails.

    Inputs: resolution (STRING, default 1024x1024) and scale_factor (FLOAT, default 1). Outputs: width (INT) and height (INT).

    Why the scale factor is the useful part

    Most nodes of this kind just split the string. The scale_factor is what makes it worth having: need to feed an upscale pass at 2×? Set scale_factor to 2 and the same 1024x1024 string becomes 2048x2048 without a second node. You keep one human-readable resolution in one place, and any node downstream can derive its own dimensions from it. It's a small thing that quietly removes a whole class of "wait, why is my latent 512 wide" bugs.

    Wire the outputs anywhere an INT dimension is expected - Empty Latent Image's width/height, an image resize node, a latent upscale - and if the resolution comes from a string you already have elsewhere in the workflow (say, from a config file or a Format String node), this becomes the single conversion point.

    Where people get burned

    The strict parser. 1024x1024 works; 1024×1024 with a unicode multiplication sign, or 1024,1024, or 1024x1024x4, does not - red node, error message, nothing else. Also remember scale_factor truncates rather than rounds: 0.6 on 1024 gives you 614, not 614.4. And since both outputs are INT, don't expect fractional dimensions no matter what factor you set.

    Install

    It ships in ComfyLab Pack, so:

    cd ComfyUI/custom_nodes
    git clone https://github.com/bugltd/ComfyLab-Pack.git
    cd ComfyLab-Pack
    pip install -r requirements.txt
    

    Or ComfyUI Manager → ComfyLab Pack, then restart. No model files, no special setup - the pack's only notable dependency is opencv-python. For a resolution string that has to survive being passed around and multiplied, this is the tidy way to do it.

    CategoryComfyLab/utils

    Inputs (2)

    NameTypeDefaultDescription
    resolutionSTRING1024x1024resolution as string (ex. '1024x1024')
    scale_factorFLOAT1.0dimension multiplier

    Outputs (2)

    NameTypeDescription
    widthINTwidth
    heightINTheight