LoadRandomImage
A Random Image Batch, With Filenames You Can Actually Use
- Image(s)
- paths
- filenames
- filenames[0]_str
Loaders are supposed to be boring, and this one isn't. LoadRandomImage pulls a random batch of images out of a folder and - unlike most loaders - hands you the paths and filenames it picked, so the rest of your workflow can know what it's looking at. It's the workhorse behind Eden.art's own texture-flow demo, where a random reference image gets style-mapped onto a video, and it earns its keep whenever you want variety without rebuilding a workflow.
One string input, folder (default .), and four controls:
n_images- how many to load. The fun part:-1means "all of them," which turns it into a plain folder loader with filenames out.seed- sets the shuffle. Same seed, same selection.sort- withsorton andn_images=1, it switches into index mode: the seed picks a specific image from the sorted list instead of a random one. That one quirk is genuinely useful for poking through a dataset deterministically.loop_sequence- appends the first image to the end of the batch, for ping-pong loops.
What comes out
Four outputs, and this is where the node stands out:
Image(s)- the IMAGE batch, EXIF-transposed, converted to float RGB.paths- the full file paths of what got picked.filenames- just the base names.filenames[0]_str- the first filename as a plain STRING, which is how you thread "which image did we get" into a caption node, a filename prefix, or a log.
The other thing it does quietly: when the batch has more than one image, it crops everything to a uniform size (center-crops to a common target) so downstream nodes get a consistent tensor instead of a mixed-aspect mess. That's a real courtesy, because mixed sizes are the #1 way a batch workflow dies later on.
Installing it
Part of the Eden.art nodesuite. ComfyUI Manager β search "Eden" β install, or:
cd ComfyUI/custom_nodes/
git clone https://github.com/edenartlab/eden_comfy_pipelines.git
cd eden_comfy_pipelines
pip install -r requirements.txt
Restart, and it's under Eden π±/general. Expect the pack's shared dependencies (scikit-learn, transformers, opencv-python, clip-interrogator, β¦) to land in your Python environment either way.
Common issues
The big one: it validates and silently skips broken images. Files that fail to open or verify are dropped with a console note, so if n_images=3 and your folder has corrupt files, you can end up with fewer than 3 outputs - and then a downstream node complains about tensor shapes. Count your files before you blame the graph.
Also, n_images=-1 + sort + loop_sequence together is a combination worth being deliberate about: all images, sorted, with the first one duplicated onto the end. That's a perfect seed for a looping animation, and a confusing surprise if you just wanted "all the images." And unlike LoadImagesByFilename, this one reads a folder directly - you can't feed it a pre-built list. Two loaders, two jobs.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| folder | STRING | . | β |
| n_images | INT | 1-1β100 | β |
| seed | INT | 00β100000 | β |
| sort | BOOLEAN | false | β |
| loop_sequence | BOOLEAN | false | β |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| Image(s) | IMAGE | β |
| paths | * | β |
| filenames | * | β |
| filenames[0]_str | STRING | β |