Latent Ratio Selector
Aspect ratios on tap, and a shuffle button when you can't decide
- latent
- ratio_used
- width
- height
The Latent Ratio Selector (class DuoUmiRatioSelector) is the Empty Latent Image node with a menu and a sense of adventure. Instead of typing 1024 into two boxes and hoping your aspect ratio works out, you pick a named preset - "2:3 Portrait", "16:9 Widescreen HD TV", "2.39:1 Anamorphic Widescreen" - and it hands you an empty latent at exactly the right resolution. It ships in the same pack as the DuoUmi wildcard node, and the two make a natural pair: random prompt, random aspect ratio, batch of 64, done.
How it works
Under the hood it's embarrassingly simple, which is the point. A lookup table of 15 presets maps each named ratio to a pixel resolution, all sized for SDXL: total pixel count hovers around a million, and every dimension is divisible by 8, so nothing fights the latent grid. The node then creates the empty tensor with torch.zeros([batch_size, 4, height // 8, width // 8]) - 4 channels at one-eighth resolution, the same shape a regular Empty Latent Image produces. Connect the latent output to your KSampler and you're done.
The interesting part is the shuffle. Set randomize to Yes and it ignores your manual pick, does random.seed(seed), and rolls a random ratio - optionally restricted by randomize_from to Portrait Only, Landscape Only, or Square Only. It's a lazy man's composition study: "I don't know if this scene wants portrait or landscape, let the die decide."
The inputs and outputs
The five inputs are all dropdowns and ints, nothing to be afraid of:
- ratio_selected - 15 presets covering portrait (2:3, 3:4, 4:5, 9:16), square, landscape (4:3, 16:9, 3:2, 21:9, plus cinematic formats), defaulting to 1:1 at 1024x1024
- batch_size - how many empty latents, up to 64
- randomize / randomize_from / seed - the shuffle controls described above
It gives you four outputs. latent is the one you wire into the KSampler; ratio_used tells you which preset actually got picked (handy when randomize is on and you forget to look); width and height are plain ints you can route into anything that wants to know the canvas size.
Installing it
Same deal as its sibling node - ComfyUI Manager, search DuoUmiWildcards, or:
cd ComfyUI/custom_nodes/
git clone https://github.com/UndefinedUo/DuoUmiWildcards
Restart and both nodes appear under DuoUmiWild. No dependencies, no model downloads.
The honest take
This isn't a node you need - the built-in Empty Latent Image does the same job with two numbers. What it adds is convenience and randomization: named presets you don't have to remember, and a seeded random mode that's genuinely fun for exploration. The one real trap is that these presets are tuned for SDXL. If you're generating on an SD1.5 checkpoint, a million pixels is overkill and the 16:9 preset will come out soft; drop the resolution yourself or stick to the smaller portrait options. And if you want a ratio that isn't in the 15, you'll still be reaching for the plain empty-latent node - the menu is fixed.
It's a utility, not a magic bullet. But when you're batch-dumping fifty prompt variations and want the aspect ratio to vary too, having the shuffle in the same pack as the wildcard node is the whole point.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| ratio_selected | COMBO | 1:1 Square - 1024x1024 | 15 options: 2:3 Portrait - 832x1248, 3:4 Standard Portrait - 880x1176, 4:5 Large Format Portrait - 912x1144, 9:16 Selfie & Social Media - 768x1360, 1:1 Square - 1024x1024, 4:3 SD TV - 1176x880, +9 |
| batch_size | INT | 11–64 | — |
| randomize | COMBO | No | Randomly select from all ratios (ignores ratio_selected) |
| randomize_from | COMBO | All | When randomize is Yes, select from this category |
| seed | INT | 00–18446744073709550000 | Seed for random ratio selection (when randomize is Yes) |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | — |
| ratio_used | STRING | — |
| width | INT | — |
| height | INT | — |