Retrieve random pair of size from array
Roll a random image size from a list, every run
- width
- height
SizeFromArray does exactly one thing: you give it a list of width,height pairs, and it hands back one of them at random. That's the whole node, and honestly that's why it's useful - it's the missing "shuffle my resolution" widget for people running batches.
Here's the workflow context. In ComfyUI the image size is set way upstream, at the Empty Latent Image node, and everything downstream (sampler, VAE decode) inherits it. The resolution is a latent-space decision before a single pixel exists. So if you're queuing fifty generations of the same character and you want variety in aspect ratio instead of the same square crop over and over, you want something to change that width/height per run. That something is this node: wire its two outputs into Empty Latent Image's width and height, and each roll picks a different canvas. It's also a tidy way to test which of your preset aspect ratios a model actually likes before you commit to one.
How it works
The mechanism is trivial but the seed handling is the part worth knowing. The node splits the sizes box into lines, skips blank ones, parses each line as int,int, then rolls one pair using numpy's default_rng seeded by the seed input. Same seed, same pick - every time. Change the seed, get a different pair.
Two practical consequences:
- The
seedwidget behaves like every seed widget in ComfyUI. Because it's namedseed, it gets the usual randomize/increment dice controls, so set it to Randomize and each queued run rolls a new size automatically. - It does not use ComfyUI's shared RNG. The pick comes from numpy's own generator, so don't expect this node's seed to correlate with anything else in the graph. It doesn't need to - it just needs to change between runs.
Inputs and outputs
Only two inputs, both required:
- sizes - a multiline string, one
width,heightper line. Default is512,512/512,768/768,512. Blank lines are ignored; that's from the source, not a guess. - seed - an INT from 0 up to 2^64−1. Seed 0 is the default.
Outputs are exactly two INTs, width and height. They only exist to feed Empty Latent Image (or anything else that takes a bare integer size, like a resize node).
Installing it
No dependencies, no model files, no requirements.txt - it only uses numpy, which ComfyUI already ships. Easiest path is ComfyUI Manager: search for SizeFromArray, install, restart. Or do it by hand:
cd <ComfyUI directory>/custom_nodes
git clone https://github.com/ITurchenko/ComfyUI-SizeFromArray.git
Restart ComfyUI and it appears in the node menu under SizeFromArray (display name "Retrieve random pair of size from array").
Where people get burned
The one real failure mode is formatting. Every line must be plain width,height with an ASCII comma - no 512x512, no 512, 768 with a space after the comma, no floats. The node calls int() on each part and has no error handling, so a malformed line kills the run with a raw traceback. Check your lines before you queue a big batch, because a typo at generation 47 will only make itself known at generation 47.
Beyond that, the only trap is expecting change with a fixed seed. Keep the seed at 0 and you'll get the same size every run, forever. That's not a bug - it's what makes the node reproducible. Randomize the seed and let it roll.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| sizes | STRING | 512,512 512,768 768,512 | — |
| seed | INT | 00–18446744073709550000 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |