ComfyUI Node

WidthHeight01

The Width/Height node with a Swap button you'll actually use

By mittimi·Created 2 years ago·Updated 6 months ago· 3
WidthHeight01
    • width
    • height
    Width512
    Height512
    preset

    WidthHeight01 looks insultingly simple - two INT inputs, two INT outputs, and Python that does nothing at all - and that's exactly why you'll end up keeping it. It ships in mittimi's tiny ComfyUI_mittimiWidthHeight pack, a collection of "why doesn't ComfyUI do this already" utilities from a Japanese blogger who cheerfully admits he wrote them because searching for an existing node was slower than building one. He's not wrong, and this one earns its place.

    The problem it solves is real. You're fine-tuning a portrait: 512 wide, 768 tall. Then you flip to landscape and you're re-typing both numbers or nudging two sliders one digit at a time. That two-second chore is exactly the kind of thing that breaks your focus mid-workflow, and it recurs every time you switch orientation. This node's Swap button does it in one click - hit it and the width and height values trade places, right there on the node.

    How it works

    The Python half is a faithful passthrough: runWidthHeight just returns the two INTs it got. All the magic lives in the pack's front-end web.js. It registers a button widget that swaps the two values, and a preset dropdown that writes both width and height at once.

    Those presets aren't hardcoded. At startup the node reads presets/presets.toml from the pack folder and pulls out every NxN pattern, which is where the seven options you see come from (512x768, 832x1280, 1024x1536, 480x720, 640x960, 720x1280, 1080x1920). Open that TOML, add your own line like wh = "... 896x1152, ...", restart ComfyUI, and your sizes show up in the dropdown. Editing the file only takes effect on restart, since the list is loaded once when the node class is registered.

    The inputs and outputs

    • Width (INT, default 512) and Height (INT, default 512) - plain integers, range up to a practically unlimited max.
    • preset (optional) - the dropdown that sets both at once.
    • Outputs width and height - wire these straight into Empty Latent Image, or any sampler resolution input.

    Nothing clever to configure. The Swap button is UI-only, so it never corrupts the graph state on load - the values you save are just plain ints.

    Install

    The pack has no requirements.txt and no model files, so this is about as friction-free as custom nodes get. Easiest is ComfyUI Manager: search for mittimi or ComfyUI_mittimiWidthHeight and hit Install. Or do it by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/mittimi/ComfyUI_mittimiWidthHeight
    

    Then restart ComfyUI. The node lands under mittimiTools in the node menu.

    Gotchas

    • Edit presets/presets.toml and forget the restart, and you'll stare at an unchanged dropdown for a while wondering what broke. Restart.
    • Only \d+x\d+ patterns get picked up from the file - write 800x1000, not 800 × 1000.
    • The author is upfront about being a hobbyist: if something misbehaves, expect to debug it yourself.

    Is it a life-changer? No. But it's three seconds of friction removed on every single workflow, and after a day of portrait/landscape flips you'll notice it's gone if you remove it.

    CategorymittimiTools

    Inputs (3)

    NameTypeDefaultDescription
    WidthINT5121–2147483647
    HeightINT5121–2147483647
    presetoptCOMBO7 options: 512x768, 832x1280, 1024x1536, 480x720, 640x960, 720x1280, +1

    Outputs (2)

    NameTypeDescription
    widthINT
    heightINT