Nodes/Chye ComfyUI Toolset/πŸ”’ CYH Math | A B Switch Res 32 Step
ComfyUI Node

πŸ”’ CYH Math | A B Switch Res 32 Step

A resolution node that only earns its keep in one setup

By chyerΒ·Created about a year agoΒ·Updated 6 months agoΒ· 1
πŸ”’ CYH Math | A B Switch Res 32 Step
    • width
    • height
    β—„width512β–Ί
    β—„height512β–Ί
    β—„swap_orderfalseβ–Ί

    Here's the honest version: this node takes a width and height, rounds both to the nearest multiple of 32, optionally swaps them, and outputs them back. That's it. There's no tensor math, no latent, no magic - it's a two-integer pass-through with a rounding rule and a flip switch.

    Which makes it a node you'll either use constantly in one very specific workflow, or never. Let me be clear about which.

    What it's actually for

    It sits in the Chye ComfyUI Toolset's math category, and its real job is normalizing resolutions that come from somewhere unconstrained. If a resolution is flowing into your graph from an image's actual dimensions, a text-parsing node, or a user-entered string, it might be 1345Γ—767 instead of 1344Γ—768 - and ComfyUI's VAE/attention layers are happier with multiples of 32. This node enforces that.

    The other half is the swap_order boolean. Flip it and width/height trade places - a portrait/landscape toggle you can wire to a switch node or a frontend checkbox.

    How it works

    The code is tiny and does exactly what the display name says (the "32 Step" is the UI step size):

    processed_width = round_to_multiple(width, 32)
    processed_height = round_to_multiple(height, 32)
    if swap_order:
        return (processed_height, processed_width)
    return (processed_width, processed_height)
    

    round_to_multiple rounds to the nearest multiple of 32 - so 1345β†’1344, 1347β†’1344, 1348β†’1344, and so on. Inputs are clamped 32–4096. Outputs are two INTs named width and height, which you'd feed into an Empty Latent Image (or a resize/latent node) that's waiting for resolution values.

    The honest catch

    Because the UI already steps the width and height inputs by 32 and clamps them to valid ranges, the "round to multiple of 32" feature does nothing when you type values in the node itself - the sliders won't even let you enter a non-multiple. The rounding only matters if width/height arrive from another node with arbitrary values. If you never feed it from upstream math or a parse node, this node is a fancy bypass, and swap_order is the only feature you'd actually use.

    So: grab it when a workflow hands you a resolution from an external source and you need it forced onto the 32-grid, or when you want a one-click portrait/landscape flip on a resolution. Skip it if you're just typing 1024Γ—1024 - the built-in Empty Latent Image already does that.

    Install

    ComfyUI Manager (search "Chye ComfyUI Toolset"), or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/chyer/Chye-ComfyUI-Toolset
    cd Chye-ComfyUI-Toolset
    pip install -r requirements.txt
    

    Restart after. This specific node has zero extra dependencies - it's pure Python - but the pack as a whole pulls scipy and opencv-python in requirements.txt, so they come along for the ride. Zip installs need .git/.cnr-id (Chye-ComfyUI-Toolset) per the README to avoid workflow-load errors.

    Verdict

    A genuinely thin utility. If you're not feeding it from an unconstrained source, the rounding is decorative. But "force these values onto a 32-grid and let me flip them" is a real need in bigger graphs, and this is the smallest tool that does it.

    Categorymath

    Inputs (3)

    NameTypeDefaultDescription
    widthINT51232–4096β€”
    heightINT51232–4096β€”
    swap_orderBOOLEANfalseβ€”

    Outputs (2)

    NameTypeDescription
    widthINTβ€”
    heightINTβ€”