Nodes/XENodes/Load Image From Folder
ComfyUI Node

Load Image From Folder

Feed a whole folder to the queue, one image at a time, untouched

By xeinherjer-dev·Created 6 months ago·Updated a day ago· 2
Load Image From Folder
    • IMAGE
    • MASK
    • filename
    • filepath
    • index
    • total_images
    pathoutput
    index0
    sort_byname
    reversefalse
    subfoldersfalse

    Stock ComfyUI's LoadImage wants you to upload or drag a file, and it resizes to a power-of-two-friendly size along the way. If your job is processing a folder of images one at a time - a batch queue, or feeding frames to a vision LLM that wants the true resolution - both of those behaviors are wrong. Load Image From Folder exists for exactly this: point it at a directory (or a single file), and it hands you one image, at its exact original resolution, with an index you can advance across the queue.

    The design is built for automation. index is a full INT input with control_after_generate support - set it to increment, randomize, whatever, just like a seed - and it wraps around: when the index exceeds the file count it loops back to the first image, so a long queue run never hits a "file not found." You can also wire the index output back into the input if you want deterministic stepping from your own logic.

    The inputs:

    • path - a directory, or a direct file path. It also resolves Windows paths to WSL paths automatically (C:\Users\.../mnt/c/Users/...), which is a small blessing if you run ComfyUI under WSL but keep files on the Windows side.
    • index (INT, default 0) - which image, with control_after_generate for queue automation.
    • sort_by - name, date_modified, date_created, or random. Random is seeded by the current index, so a given index is reproducible - same index, same "random" file, which keeps queue runs comparable.
    • reverse (boolean) and subfolders (boolean, recursive) - sort direction and whether to walk subdirectories.

    The outputs are richer than most loaders:

    • IMAGE - the exact original resolution, no resizing, shape [1, H, W, 3].
    • MASK - an alpha mask if the file has one, otherwise zeros.
    • filename and filepath (STRING) - what you loaded and where, useful for logging or renaming saves to match.
    • index and total_images (INT) - current position and how many images were found, so you can build "image 3 of 17" logic.

    It also previews the loaded image right on the node after each run, which sounds minor and turns out to be the difference between trusting a batch and babysitting it.

    Install is the pack standard:

    cd ComfyUI/custom_nodes
    git clone https://github.com/xeinherjer-dev/ComfyUI-XENodes.git xenodes
    

    or search "ComfyUI-XENodes" in ComfyUI Manager, then restart. No models, no pip deps for this node.

    Where people get burned, and it's worth saying plainly. First, no resizing means exactly that - an 8000px scan will blow through VRAM in an img2img pass if you feed it straight to a sampler; this node is built for vision-LLM and queue use, not for blindly chaining to diffusion without a resize upstream. Second, random sort makes the node uncacheable by design - it always reruns (the fingerprint is random), which is correct for its job but means it and everything downstream re-execute every run; don't be surprised by that. Third, a path that doesn't exist raises a clear FileNotFoundError, not a silent fallback. And the pack gotcha applies as always: if no XENodes nodes appear, check the console - the pack imports together, and SaveAudio's PyAV (av) import is the usual culprit.

    Categoryxenodes/image

    Inputs (5)

    NameTypeDefaultDescription
    pathCOMBOoutputSelect a folder from the output or input directory.
    indexINT00–18446744073709550000Image index. Supports auto-incrementing / randomizing via control_after_generate for batch queue runs.
    sort_byCOMBOnameSorting method for files in the directory.
    reverseoptBOOLEANfalseReverse the sort order.
    subfoldersoptBOOLEANfalseInclude images in subdirectories recursively.

    Outputs (6)

    NameTypeDescription
    IMAGEIMAGELoaded image tensor [1, H, W, 3] without resizing.
    MASKMASKAlpha mask if present, otherwise zeros.
    filenameSTRINGFilename of the loaded image.
    filepathSTRINGFull filepath of the loaded image.
    indexINTCurrent index within the image list.
    total_imagesINTTotal count of images found.