Nodes/ComfyUI-XJNodes/Load Images From Dir List
ComfyUI Node

Load Images From Dir List

Dump a whole folder of images into the graph, sorted and capped

By alexjx·Created 10 months ago·Updated 4 months ago· 0
Load Images From Dir List
    • IMAGE
    • MASK
    • FILE PATH
    directory
    image_load_cap0
    start_index0
    load_alwaysfalse
    recursivefalse

    If you've ever needed to run a workflow over fifty images without loading them one at a time, this is the node. Load Images From Dir List reads every image in a folder and hands you a list of image tensors, masks, and file paths - batch processing in one step. The README credits Dr.Lt.Data's Inspire Pack as the inspiration, which tells you what tradition it's from: the "point me at a folder and give me the batch" school of ComfyUI loaders.

    The outputs being lists (not a single batched tensor) is the important design decision. Downstream, you can iterate with the pack's loop system, feed each image through a detailer pass, or just concatenate them into one batch for batch sampling. The file paths come along for the ride, which matters more than you'd think - pairing each image with its filename is how you keep track of which output belongs to which input.

    How it works

    Give it a directory, and it scans for .jpg, .jpeg, .png, and .webp, sorts the list alphabetically, and loads each into an RGB tensor plus an alpha-derived mask (empty 64×64 mask if no alpha). The recursive toggle switches from a flat scan of one folder to an os.walk over subfolders, which is how you load a whole nested dataset in one shot. Files are loaded in sorted order, so "first N" actually means "first N alphabetically."

    Three options control the selection:

    • image_load_cap - stop after N images; 0 means no cap
    • start_index - skip the first N files
    • load_always - force a re-read on every queue run. Leave it off and ComfyUI caches results, so edits to the folder won't show up; turn it on and every run re-scans

    The recursive flag plus start_index plus image_load_cap together let you page through a big folder like a dataset iterator.

    Inputs and outputs

    • directory - the folder path as a string (absolute paths, no dropdown)
    • The four optional controls above

    Outputs, all as lists: IMAGE, MASK, and FILE PATH (the full path string per image).

    Installing it

    Part of the XJNodes pack. ComfyUI Manager → search "ComfyUI-XJNodes" → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/alexjx/ComfyUI-XJNodes
    # restart ComfyUI
    

    No dependencies to add. It appears under XJNodes/image.

    Where to be careful

    First, this is another "give me a real path" node - it doesn't know about ComfyUI's input-folder dropdown, and it raises FileNotFoundError if the directory doesn't exist or contains no valid images. Second, "list" is doing real work here: if your downstream node expects a batched IMAGE tensor (shape B×H×W×C) and you feed it a list, you'll get type errors. The pack's list utilities - and the loop system specifically, which was built to preserve lists as-is - are the intended companions. Third, watch memory: recursive on a 10,000-image dataset is 10,000 tensors in one go. Cap it or you'll find out what your RAM ceiling actually is. For single-image dynamic loading by path, the pack's Load Image By Path is the sibling to reach for instead.

    CategoryXJNodes/image

    Inputs (5)

    NameTypeDefaultDescription
    directorySTRING
    image_load_capoptINT0
    start_indexoptINT00–18446744073709550000
    load_alwaysoptBOOLEANfalse
    recursiveoptBOOLEANfalse

    Outputs (3)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK
    FILE PATHSTRING