Nodes/Ostris Nodes ComfyUI/Batch Image Loader - Ostris
ComfyUI Node

Batch Image Loader - Ostris

One image per run, caption included

By ostris·Created 3 years ago·Updated about a year ago· 49
Batch Image Loader - Ostris
    • image
    • filename
    • filename_no_ext
    • folder_path
    • full_path
    • caption
    folder_path

    The name is a small lie, and it's worth clearing that up before anything else. Batch Image Loader - Ostris does not hand you a folder full of images as one big IMAGE batch. Instead, it hands you one image per workflow run and quietly advances through the folder each time you hit Queue. If that's what you actually want - and for caption-aware folder processing it usually is - this is a handy little node.

    Here's the mechanism, from the source. The loader keeps a queue of image paths in memory. Every time it executes, it pops the next path off the queue, loads that image, and returns it along with its filename and caption. It also reports to ComfyUI, through the IS_CHANGED hook, that the next queued image is different from the last one - which is what makes ComfyUI re-run the downstream graph on the next queue press. Net effect: press Queue, get image 1; press Queue, get image 2; and so on until the folder is exhausted, at which point it rescans the folder and starts over. It's the classic "iterate a folder one pass per run" pattern, built for img2img and caption-preserving passes over a dataset directory.

    The single input is folder_path, a string pointing at a directory. It remembers the last folder you used and pre-fills the box next time. Outputs:

    • image - the loaded image
    • filename / filename_no_ext - full filename and filename minus extension
    • folder_path / full_path - where the image lives, for saving back or tracking
    • caption - text from a same-name .txt or .caption sidecar file, lines joined with commas

    The caption handling is the reason to reach for this over a plain folder loader. If your folder has photo_001.jpg and photo_001.txt next to it, the caption arrives pre-joined and ready to feed a conditioning encode. No caption file, no problem - the port just comes back empty. It only picks up jpg, jpeg, png, webp, and tiff, applies EXIF orientation correction automatically, and skips any file that fails to load (a corrupt image won't kill the run, it'll just advance to the next one).

    Where people get burned:

    • The one-per-run thing. If you genuinely want a whole folder as a single batch tensor for parallel generation, this isn't the node - you want a "load all images in folder" loader. This one is sequential by design.
    • Wrong path = hard error. Point it at a folder that doesn't exist and it raises an exception and stops the run. Check the path first.
    • The queue is in memory. Restart ComfyUI and the queue is gone; it'll just rescan the folder, which is usually what you want anyway.

    Install it with the rest of the pack - ComfyUI Manager, search Ostris Nodes, restart, or:

    cd <your_comfyui_folder>/custom_nodes
    git clone https://github.com/ostris/ostris_nodes_comfyui.git
    cd ostris_nodes_comfyui
    pip install --upgrade -r requirements.txt
    

    It ships from the same early-2025 Ostris commit as Save Image Direct, and the two are a natural pair: load a folder's images one at a time here, process them, and save them back with captions intact using Save Image Direct. If you do batch img2img over a captioned dataset, that pairing alone justifies the pack.

    Categoryostris/batch

    Inputs (1)

    NameTypeDefaultDescription
    folder_pathSTRING

    Outputs (6)

    NameTypeDescription
    imageIMAGE
    filenameSTRING
    filename_no_extSTRING
    folder_pathSTRING
    full_pathSTRING
    captionSTRING