Load Images From Folder (KJ)
Batch a whole directory into one workflow
- image
- mask
- count
- image_path
When you need to run a workflow over a pile of images - a whole folder of them - you don't want to load them one at a time. Load Images From Folder (KJ) points at a directory and pulls every image in it into a single batch, resized to a common size so they stack cleanly. Its description is exactly this: "Loads images from a folder into a batch, images are resized and loaded into a batch." It's the front door for bulk processing: batch upscaling, batch img2img, feeding a folder of frames into a video workflow, dataset prep.
How it works
You give it a folder path and target dimensions. It reads the images, resizes each to those dimensions, and returns them as one batched IMAGE tensor plus some metadata. Because everything in a ComfyUI batch has to share a size, the resize isn't optional - and the node gives you control over how it makes them match, which is the part that actually matters.
The inputs that matter
- folder - the directory path to load from. This is the whole point; get the path right and most of your problems disappear.
- width / height (default 1024) - the size every image gets resized to. There's a
-1sentinel available if you want to leave a dimension unconstrained. - keep_aspect_ratio (
crop,pad, orstretch) - how to reconcile mismatched source shapes with your target size.cropfills the frame and trims overflow,padletterboxes with borders,stretchdistorts to fit.cropis usually what you want for generation;stretchis what you want almost never.
Three optional dials handle big folders: image_load_cap (stop after N images - 0 means all), start_index (skip the first N, for resuming or paging through a huge set), and include_subfolders (recurse, off by default).
Four outputs: image (the batch), mask (any alpha channels, as masks), count (how many loaded, an INT), and image_path (the paths, as a string). The count output is handy for driving downstream loops or sanity-checking you got what you expected.
Where it wires in
At the very start of a batch pipeline. The image output feeds whatever you're running over the set - an upscaler, a sampler in img2img mode, a color-match pass. image_load_cap and start_index together let you process a giant folder in chunks so you don't try to hold ten thousand images in VRAM at once.
Installing it
Part of kijai's KJNodes pack.
- ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
- Manual -
cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, thenpip install -r requirements.txt, and restart.
No dependencies of note.
Common issues
Path problems are 90% of the support questions on nodes like this. The folder path has to be one ComfyUI can actually see from where it's running - an absolute path is safest, and on a remote or containerized ComfyUI (like a cloud instance) "my desktop folder" isn't reachable at all. If the node loads nothing, check the path before anything else.
The other big one is memory. A folder-load builds one batch, and a batch of hundreds of 1024px images is a lot of tensor to hold at once - that's how you OOM before the sampler even starts. Use image_load_cap to process in manageable chunks, and start_index to walk through the rest across runs. Finally, mind keep_aspect_ratio: if your outputs come back squished, you're on stretch when you wanted crop or pad.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| folder | STRING | — | |
| width | INT | 1024 | — |
| height | INT | 1024 | — |
| keep_aspect_ratio | COMBO | 3 options: crop, pad, stretch | |
| image_load_capopt | INT | 0 | — |
| start_indexopt | INT | 0 | — |
| include_subfoldersopt | BOOLEAN | false | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| count | INT | — |
| image_path | STRING | — |