Resolution and Ratio
A Resolution and Ratio Control Panel for ComfyUI
- width
- height
The name undersells it and oversells it at the same time
This node doesn't upscale anything, generate anything, or load a single model file. It's a control panel for the two integers that decide your generation size - and it exists because if you swap between portrait and landscape as often as most of us do, retyping 1216x896 into an Empty Latent Image for the hundredth time gets old fast.
ResolutionAndRatio gives you a preset dropdown, a scale slider, aspect-ratio fields that keep the other dimension honest, and swap/reset buttons, then hands you two clean integers to wire into whatever wants them. Every model has a native resolution it was trained at (SDXL's trained bands include 1152x896, 1216x832, and friends - wander too far and you get stretched anatomy or tiling), so a node that keeps you inside sane sizes is a quiet productivity win, not a gimmick.
How it works - a dumb backend and a smart frontend
The Python side is almost insultingly simple. It takes width and height, optionally swaps them or resets them to 256x256, rounds each to the nearest multiple of 32, clamps to the 64–4096 range, and returns two INTs. That's it.
All the interactive magic lives in the frontend JS that ships in the pack's web/ folder. The preset dropdown is literally populated by parsing the custom_presets text box for lines containing an "x", the scale slider rescales your current base resolution in real time, and the ratio fields recompute the matching dimension for you. There's no hidden state being synced to the backend - the ratio and scale widgets are UI conveniences that just write new values into width/height.
That split matters for one practical reason: zero dependencies. Pure Python stdlib, no requirements.txt, no models to download, no GPU code. The README brags "hardly requires any dependency fuss" and it's the rare case where the README is telling the truth.
The inputs and outputs that matter
width/height- the actual numbers. Defaults are 1152x1536, a solid 3:4 SDXL-era portrait.W_ratio/H_ratio- aspect ratio, e.g. 3:4. Change one and the node recomputes the other dimension for you, rounded to 32. If the result would blow past 4096 it clamps the ratio instead of the canvas.scale_percent- a 10–200% slider that rescales the current base resolution live. Great for "same framing, twenty percent bigger" without touching ratios.preset+custom_presets- the dropdown starts as "Custom" and then fills itself from the lines of thecustom_presetsbox. Want your own sizes? Type oneWxHper line and they appear.reset/swap- momentary buttons that flip back off after a beat.resetdumps you to 256x256;swapflips width/height and both ratios.
Outputs: width (INT) and height (INT), wired straight into an Empty Latent Image node - or anywhere else that accepts an INT.
Install
Via ComfyUI Manager: Install Custom Nodes, search "ComfyUI_Resolution-and-Ratio" (shown as "Resolution and Ratio"), install, restart. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/SamLiu1000/ComfyUI_Resolution-and-Ratio
Then restart ComfyUI. No pip installs, no model files, no caveats.
Where people get burned
The 32-rounding is the big one. It's nearest multiple, not a floor, and it's by design - the README says every resolution divides by 32, which keeps latents tidy. But type 1000x1000 and you'll get 992x992 back. If you need exact pixels, this node will quietly betray you.
Also: a dropdown that only shows "Custom" isn't broken - the preset list builds in JS shortly after the node loads, so give it a moment or restart ComfyUI if it never fills. And remember the ratio fields are UI-only; this node's entire job is producing clean width/height, not changing what a checkpoint was trained to render. If you already hardcode sizes in saved workflows, this is redundant. If you're the type who re-rolls between portrait and landscape all day, it's the dependency-free QoL gadget you'll actually reach for.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 115264–4096 | — |
| height | INT | 153664–4096 | — |
| W_ratio | INT | 31–100 | — |
| H_ratio | INT | 41–100 | — |
| scale_percent | INT | 10010–200 | — |
| reset | BOOLEAN | false | — |
| swap | BOOLEAN | false | — |
| preset | COMBO | 1 options: Custom | |
| custom_presets | STRING | 128x128 256x256 512x512 512x768 768x768 1024x1024 896x1216 1216x896 1088x1920 1920x1088 1152x1536 1536x1152 1536x2048 2048x1536 2048x2048 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |