Random Width/Height with Resolution
Seeded aspect-ratio picker for batches
- INT
- INT
This one's smarter than it looks. Give it a target resolution and a range of aspect ratios, and it picks a random width and height that stays around that resolution - snapped to clean multiples, and driven by a seed so it's reproducible. Out come two integers: a width and a height. It's a proper little dimension generator for anyone who wants variety without babysitting it.
Where it earns its keep is batch generation. If you render 50 images all at the same fixed 1024×1024, you get 50 square compositions and the model never stretches into the wide or tall framings it also knows. Feed those dimensions from this node instead and each run rolls a different aspect ratio - some portrait, some landscape, some near-square - while the total pixel budget stays roughly constant, so your VRAM and timing stay predictable. That's how you get a varied, natural-feeling set instead of a wall of squares.
The training-world pedigree
It's no surprise this comes from aria1th (AngelBottomless), the trainer behind the Illustrious XL models. Aspect-ratio bucketing - grouping training images into a set of resolutions that all share a similar pixel count - is a core technique in modern diffusion training, and it's exactly the logic this node implements at generation time. Someone who spent their time preparing enormous image sets for training would reach for this shape of tool by instinct.
The inputs that matter
- resolution (default 1024) - the target pixel budget the chosen width×height stays around.
- min_ratio (default 0.6) and max_ratio (default 1.6) - the range of aspect ratios it's allowed to pick from. 0.6 is tall/portrait, 1.6 is wide/landscape, 1.0 would be square. Widen the range for more variety, narrow it to keep compositions closer to a shape you want.
- multiples (default 32) - both dimensions are snapped to a multiple of this, so the output is model-friendly (no ragged sizes that upset the VAE or tiling). 32 or 64 is standard.
- seed - the same seed always yields the same width/height pair, so results are reproducible; change it to roll a new one. This is what makes it a seeded picker rather than pure chaos.
The outputs are two INT values - width and height - that you wire into an empty-latent node or wherever your workflow sets canvas size.
Installing ComfyUI-LogicUtils
ComfyUI Manager: Install Custom Nodes → search "ComfyUI-LogicUtils" → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/aria1th/ComfyUI-LogicUtils
Restart ComfyUI. No dependencies.
Worth knowing
The pack is undocumented by the author's own admission, but this node's behavior is exactly what its inputs suggest. One tip: keep min_ratio and max_ratio sensible for your model - pushing to extreme ratios can produce dimensions where SDXL-class models start duplicating subjects or losing coherence. Moderate ranges around a 1024-ish budget give you variety that still generates cleanly.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| resolution | INT | 1024 | — |
| min_ratio | FLOAT | 0.60 | — |
| max_ratio | FLOAT | 1.60 | — |
| multiples | INT | 32 | — |
| seed | INT | 0 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |
| INT | INT | — |