ComfyUI Node

WidthHeight

Preset resolutions and a Swap button — a friendlier way to manage Width and Height

By mittimi·Created 7 months ago·Updated 6 months ago· 0
WidthHeight
    • width
    • height
    Width512
    Height512
    preset

    WidthHeight is a control panel for image dimensions. You get a Width and a Height integer input, an optional preset dropdown, a Swap button, and two integer outputs - width and height. It exists to save you from typing "1344 x 768" a dozen times and to make flipping portrait to landscape a single click.

    Why you'd reach for it

    Aspect-ratio management is the job. Instead of hunting through Empty Latent Image's widgets every time, you keep one WidthHeight node feeding your graph's dimensions, and you can also wire the ints into a KSampler, an image resize, or any node that takes separate width/height integers. One place to change dimensions, and the whole graph follows.

    The preset dropdown is where it earns its keep. It ships with seven presets: 512x768, 832x1280, 1024x1536, 480x720, 640x960, 720x1280, 1080x1920. Notice something? They're all portrait. Every single one. That's not an accident - it's why the Swap button exists. Pick 1024x1536 for portrait, hit Swap, and you've got 1536x1024 landscape without typing a thing. If you work mostly in vertical formats - phone wallpapers, short-form video at 720x1280 or 1080x1920 - this feels purpose-built for you.

    How it works

    The Python side is a pure passthrough - it literally returns the Width and Height you gave it:

    def widthHeightMittimi(self, Width, Height, node_id, preset=[]):
        return (Width, Height, )
    

    All the real behavior lives in the frontend JavaScript that ships with the pack. When you pick a preset, the extension splits it on the x and writes both numbers into the Width and Height widgets. The Swap button just exchanges the two widget values. So the outputs always mirror what the Width and Height widgets currently show.

    One nice detail buried in that JS: the preset override is disabled while a workflow is being loaded (allow_set_flag flips off during graph configure). That means loading a saved workflow keeps your saved dimensions instead of having the current preset silently clobber them. Small touch, but it shows the author thought about the obvious footgun.

    The inputs that matter

    • Width - integer, default 512.
    • Height - integer, default 512.
    • preset - optional dropdown of the seven fixed resolutions. Pick one and it fills Width/Height in for you.

    Outputs are width and height, both INTs, which you wire wherever your graph needs dimensions - most commonly into Empty Latent Image's width and height inputs.

    Installing it

    Part of mittimi/ComfyUI_mittimiTools, a small five-node pack by mittimi whose README is literally "some tools." Install via ComfyUI Manager (search ComfyUI_mittimiTools) or:

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

    Restart ComfyUI afterward. The only dependency is toml, which ComfyUI already ships, so no extra pip installs and no model downloads.

    The honest caveats

    The preset list is fixed and lives in presets/width_height/presets.toml - but the pack reads that file at startup, so you can edit it and add your own WxH entries (it regex-scans for \d+x\d+). You'll need to restart ComfyUI for changes to show up. Also note the Swap button only swaps the Width/Height widgets - the preset label doesn't update to match, so after a swap the dropdown will show a value that no longer reflects your actual dimensions. Cosmetic, but it throws people.

    At the end of the day this is a convenience node, not a requirement - Empty Latent Image will get you there on its own. But if you flip orientation constantly or want one shared place to manage dimensions across a busy graph, it's a small quality-of-life win. And if the pre-set portrait ratios annoy you, you now know where to fix it.

    CategorymittimiTools

    Inputs (3)

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

    Outputs (2)

    NameTypeDescription
    widthINT
    heightINT