Load Images From Dir Batch
Load a whole folder of images as one batch, Inspire-Pack style
- IMAGE
- MASK
- INT
The stock Load Image handles one file at a time, which is fine until you want to process a directory of crops, a batch of input photos, or a dataset folder. XJLoadImagesFromDirBatch is the "grab everything from this folder" loader: point it at a path and it returns the whole directory as a single IMAGE batch (plus a matching MASK output and a count), with optional recursive traversal, a cap on how many to load, and a start offset.
The README credits Dr.Lt.Data's Inspire-Pack as the inspiration, and you can feel it: this is the same "Load Images From Dir" idea, trimmed down and dependency-free. Given that the pack is one developer's personal toolkit, this is the node people actually reach for when they'd rather not install the whole Inspire suite just for a folder loader.
How it works
Point directory at any path (absolute, or relative to where ComfyUI runs), and it walks it collecting .jpg, .jpeg, .png, and .webp files - recursively if you flip recursive on. Then comes the interesting part, inherited from the Inspire approach: all images are resized to match the largest one, so mixed-size folders still come out as a single stackable batch instead of a shape error. Alpha channels get pulled out into an inverted MASK output (ComfyUI's convention), which makes it genuinely useful for compositing batches of transparent PNGs.
image_load_cap limits how many frames you get (0 = no limit), and start_index lets you skip ahead in the sorted file list - -1 grabs just the last file. load_always is the gotcha-be-gone flag: when on, it makes the node return a "changed" signal every single run, so it re-reads the directory even if nothing else in the workflow changed. Turn it on when you're adding files to the folder between runs and ComfyUI keeps showing you stale results.
Outputs are IMAGE, MASK, and INT (the number of images loaded) - that count is handy for loop math or reporting.
The inputs that matter
directory(STRING) - the folder to load. The one thing you can't skip.image_load_cap- stop after N images;0loads everything.recursive- include subfolders.load_always- force a reload each execution.
Installing it
Part of ComfyUI-XJNodes, one-time install:
cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-XJNodes
then restart ComfyUI (or ComfyUI Manager → search ComfyUI-XJNodes). No models, empty requirements.txt - this one leans on ComfyUI's own upscaling helpers.
Common issues
Two things bite people. First, mixed-size directories get upscaled to the largest, which can waste VRAM if one huge PNG drags everything up - pre-crop your folder if you're memory-constrained. Second, the error "No valid image files found" means the path is wrong or the folder is empty; the node only handles those four extensions, so .gif or .bmp files are silently ignored. And remember load_always: the classic complaint of "I added files but ComfyUI didn't see them" is usually that flag being off.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | — | |
| image_load_capopt | INT | 0 | — |
| start_indexopt | INT | 0-1–18446744073709550000 | — |
| load_alwaysopt | BOOLEAN | false | — |
| recursiveopt | BOOLEAN | false | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| INT | INT | — |