⭐ Star Random Image Loader
Grab a random image from a folder, seed-locked when you need consistency
- image
- mask
- image_path
- seed
Sometimes you don't care which image - you just want A random image, from a folder, into your workflow. Star Random Image Loader is the no-fuss version of that: point it at a directory, and each run it picks a random image and feeds it (plus its alpha as a mask) into your graph. Think style-transfer batches, img2img roulette, training-data shuffling, or "surprise me" inputs for a creative loop.
The genuinely useful detail is the seed. With seed = 0 (the default) every run picks a new random image; set a nonzero seed and the same image comes back every time. That turns it into a debugging tool - "the run that broke used this image" - and makes your random picks reproducible inside a batch loop. The seed also comes out as an output, so you can see (and store) which image you actually got.
How it works
- folder - required. The directory to pick from.
- include_subfolders - recurse into subfolders or not.
- seed -
0= fresh random each run; nonzero = deterministic pick.
Outputs: image (IMAGE), mask (MASK - the image's alpha channel, if any), image_path (STRING, so you know what you loaded and can feed the path elsewhere), and seed (INT).
The mechanism is worth a note: the node's IS_CHANGED hook returns random.random() when the seed is 0, which is what forces ComfyUI to treat every run as "changed" and actually execute - that's how you get a different image each time without touching the widgets.
Install
Part of the Starnodes2024/ComfyUI_StarNodes pack:
cd ComfyUI/custom_nodes
git clone https://github.com/Starnodes2024/ComfyUI_StarNodes
cd ComfyUI_StarNodes
pip install -r requirements.txt
Restart, search star. No extra dependencies.
Where people get burned
If folder points at a nonexistent or empty path the node raises a clear Folder ... cannot be found error - but note it's an absolute filesystem path, not one relative to your ComfyUI root. The subtler gotcha: with seed 0, downstream nodes that cache outputs may not re-run unless the loader's changed-signal propagates, so if your downstream feels "stuck" on the same image, force a re-execute. And remember the mask output only has content when the source image actually has an alpha channel - a flat JPG gives you an empty mask.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| folder | STRING | — | |
| include_subfoldersopt | BOOLEAN | false | — |
| seedopt | INT | 00–18446744073709550000 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| image_path | STRING | — |
| seed | INT | — |