Load Image Batch From Dir
Load a whole folder of images in one node — Load Image Batch From Dir
- IMAGE
- MASK
- INT
Dragging fifty images into ComfyUI one at a time is a slow way to spend an afternoon. wcx_LoadImagesFromDirBatch is the node for when you have a folder full of files and you want them all as one batch in a single node - for a batch img2img pass, a style transfer run, a comparison set, whatever. It points at a directory and turns its contents into an IMAGE batch, a MASK batch, and a count.
What it actually does, from the source: it lists the directory, keeps the image files (.jpg, .jpeg, .png, .webp - plus .jxl if you've installed pillow-jxl), optionally sorts them, skips ahead by start_index, and loads up to image_load_cap of them (0 means no limit). It transposes EXIF orientation as it goes, so your phone photos come out the right way up - a small touch that a lot of loaders skip. For each image it emits an RGB tensor and a mask built from the alpha channel (inverted per ComfyUI convention, so transparent areas read as masked). Images with no alpha get a tiny 64×64 empty mask. The third output is the INT count of images loaded.
The knobs that matter:
- directory - the only required input. Give it an absolute path; it won't browse your folders for you.
- sort_method - None, Alphabetical, Numerical, or Datetime, each ASC/DESC. Numerical is the one you want for
frame_001.png…frame_120.pngsequences, since alphabetical would order themframe_1, frame_10, frame_2.start_indexapplies after sorting, so sorting first means "skip the first N in this order." - load_always - when on, the node reruns every execution, picking up files added since last run. It does this with the
IS_CHANGED→ NaN trick the plumbing KB doc warns about: NaN never equals itself, so the cache is defeated. Useful for a folder you're actively dropping files into; annoying if you leave it on, because it poisons the cache for everything downstream of the loader.
The traps are real and mostly silent:
- Mixed-resolution folders get squashed. If the images aren't all the same size, everything after the first is resized (bilinear) to match it. That's often what you want for a batch pass, but it's automatic - feed in a folder with one odd-sized image and it just quietly resizes.
- Missing or empty directory is a hard error. It raises
FileNotFoundErrorrather than passing through an empty batch. A folder that exists but has no valid images does the same. - The mask is only meaningful for PNGs with transparency. For everything else you get a dummy 64×64 mask. Don't wire it into a mask workflow expecting real data unless your files actually have alpha.
Install is the pack's standard light route:
# ComfyUI Manager: search "ComfyUI-Practical-Tools" → Install → restart
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/wenchengxiang/ComfyUI-Practical-Tools
# restart ComfyUI
No model files, no requirements file. For .jxl support you'd add pip install pillow-jxl yourself, but that's optional and most people never need it. This is the node that turns a directory of frames into "one wire" - and with Numerical sorting and start_index, it's a proper batch loader, not just a folder reader.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | — | |
| image_load_capopt | INT | 0 | — |
| start_indexopt | INT | 0-1–18446744073709550000 | — |
| load_alwaysopt | BOOLEAN | false | — |
| sort_methodopt | COMBO | 7 options: None, Alphabetical (ASC), Alphabetical (DESC), Numerical (ASC), Numerical (DESC), Datetime (ASC), +1 |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| INT | INT | — |