CNP Random Resolution
Let your workflow roll its own aspect ratio
- width
- height
- resolution
CNP Random Resolution picks a width and height for you, on a grid, from a seed you control. The point is exploration: instead of hand-setting 1024×1024 and hoping, you let a run grab a random aspect ratio from a sensible list - 512×1024, 1024×1536, 2048×1024 - and see what the model does with it. That's the batch-variation workflow ComfyUI is uniquely good at, except here the thing varying is the canvas, not just the seed.
Everything it emits is a multiple of base_unit, so with the default 512 you get 512, 1024, 1536, 2048 - all multiples of 64, which keeps the VAE happy. No off-grid sizes that make latents or the VAE complain.
Three modes
fixed- usesfixed_width_stepsandfixed_height_stepsdirectly. No randomness at all; effectively a nicer way to type a resolution.random- picks a step count for width and for height independently.random_ratio(default) - builds a curated set of aspect ratios from common pairs (1:2, 2:3, 3:4, and their landscapes) then picks one. This is the "surprise me, but make it sane" mode.
Inputs that matter
mode- the three above.base_unit- the grid size. 512 for SD1.5-era models, 1024 for SDXL/Flux native resolution. Step is 64, so you can't emit a dimension the VAE will choke on.min_steps/max_steps- the range of base_units per side. Defaults 1–4, meaning 512–2048 at base 512.orientation-any,square,portrait, orlandscape. Force the shape when you need it.ratio_mode-common(both orientations),vertical_common,horizontal_common, orfree(any combination of steps).seed- same seed, same resolution, every time.
Outputs
width (INT) and height (INT) go straight into the Empty Latent Image node's width/height inputs. There's also a resolution STRING ("1024 x 1536"), handy for a caption or to hand to CNP Format when you're saving images named by size.
The gotcha that will trip you up
The seed is a plain INT widget, not a ComfyUI seed control. There's no "randomize after generate" built in, so with the default seed of 0 you'll get the exact same resolution on every run. Great for reproducibility, very confusing if you expected a die roll. To actually randomize, feed it a fresh seed each run (bump the value, or wire in a random-seed node) - that's the whole trick to making this node do its job.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/chemicalshock/ComfyNodesPlus
or ComfyUI Manager → "ComfyNodesPlus", then restart. No requirements.txt and no model files - it's pure Python stdlib, so it can't break your environment like the heavier utility suites.
Troubleshooting
- The node has no idea how much VRAM you have.
base_unit2048 withmax_steps4 is 8192² - a 67-megapixel latent that will OOM most cards. Dialmax_stepsdown. min_stepsgreater thanmax_steps? It silently swaps them rather than erroring.- It emits one resolution per node execution, and a fixed sampler batch shares it. For per-image variety in a batch, randomize the seed between runs rather than expecting one node call to vary mid-batch.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| mode | COMBO | random_ratio | 3 options: fixed, random, random_ratio |
| base_unit | INT | 51264–4096 | — |
| min_steps | INT | 11–32 | — |
| max_steps | INT | 41–32 | — |
| fixed_width_steps | INT | 21–32 | — |
| fixed_height_steps | INT | 21–32 | — |
| orientation | COMBO | any | 4 options: any, square, portrait, landscape |
| ratio_mode | COMBO | common | 4 options: free, common, vertical_common, horizontal_common |
| randomise_orientation | BOOLEAN | true | — |
| seed | INT | 00–18446744073709550000 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| resolution | STRING | — |