Nodes/Gprompts/Load images from folder
ComfyUI Node

Load images from folder

One image per run, no python loop required

By GadzoinksOfficial·Created about a year ago·Updated a day ago· 3
Load images from folder
    • image
    • filename_text
    • width
    • height
    • prompt
    mode
    seed0
    index0
    path
    pattern*
    allow_RGBA_output
    filename_text_extension
    load_exif

    Core ComfyUI's Load Image loads an image - the one you uploaded, every time. Fine for one-off img2img, hopeless when you have a folder of 300 test renders to walk through. The usual answer has been WAS Node Suite's Load Image Batch, and this node is a fork of it (the README credits WASasquatch) - a fork that exists because WAS Node Suite has been dormant since 2023 and people still need this job done weekly.

    So: point it at a folder and it hands you one image per run, in order, at random, or at a fixed index.

    The inputs that matter

    You set three and leave the rest alone.

    path is a folder on the machine running ComfyUI - no upload button, no file picker, just a string. Relative paths resolve from ComfyUI's working directory, so input/facerefs or output/2026-09-16 both work, and absolute paths work too. If it doesn't exist you get a flat Path does not exist: error, and since the default is an empty string, a fresh node complaining about a path you never filled in is just that.

    mode is the whole personality of the node:

    • single_image - loads the one at index (0-based). Index beyond the end wraps around.
    • incremental_image - next image each run, back to the first after the last. This is the mode you want for "walk the whole folder".
    • random - picks using seed.

    Files are filtered to png/jpg/jpeg/bmp/tiff/webp, sorted, and loaded with EXIF orientation applied, so phone photos don't come in sideways. pattern defaults to * and is a glob with recursion enabled - *.png for PNGs only, **/* to descend into subfolders.

    Then the ones you touch once: allow_RGBA_output (default false, flattening transparency to RGB - set true to keep alpha, and expect downstream nodes that want 3 channels to complain), filename_text_extension (include .png in the filename output or not), and load_exif (read file metadata so prompt can be filled).

    seed only does anything in random mode. Important trap: it's random.seed(seed) then one draw, so a fixed seed returns the same image forever. Set the seed widget's control_after_generate to randomize, or you'll conclude random mode is broken when it's being perfectly deterministic.

    The outputs

    Five: image, filename_text, width, height, prompt. The image goes into a VAE Encode, a ControlNet preprocessor, an IPAdapter reference. filename_text is sneakily useful as a save prefix, so outputs come back named after their inputs instead of ComfyUI_00042_.png. width/height can drive your latent size so the folder's images aren't silently resampled to whatever size the workflow was authored at. And prompt is the round-trip output: if the file was written by this pack's note-saving Save Image node (or its Immich sibling), the stored computed prompt comes back out and you can wire it straight into a text encoder.

    One honest limitation - prompt reads the pack's own computed_prompt chunk specifically. A regular ComfyUI save writes prompt and workflow, not computed_prompt, so a folder of default-node saves gives you an empty string. It's a within-pack handshake, not a universal metadata reader.

    Why it re-runs (and what that costs)

    ComfyUI caches hard, and a loader that returns a new image every queue would normally be cached after its first run. This node sidesteps that the standard way: IS_CHANGED returns float("NaN") for incremental and random modes, which never compares equal, so the node is forced to execute every time. That's why the folder actually advances instead of handing you image #1 forever - and the usual cost applies, since an always-dirty node makes ComfyUI re-execute everything behind it. single_image behaves better: it hashes the file and only re-runs when the file changes.

    The incremental counter is per node instance, keyed by path + pattern, and lives in memory - restart ComfyUI and you're back at image one. Two batch loaders on two folders each keep their own counter, which is what you want for "image + matching mask" runs, as long as both folders hold the same number of files in the same sorted order. If they don't, they drift, and nothing warns you.

    Install

    Manager → search Gprompts → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/GadzoinksOfficial/comfyui_gprompts
    

    Dependency list is one line - pillow. No models to download. If the pack doesn't appear at all after restart, it's almost always that the whole pack failed to import on an older ComfyUI: check the console for an ImportError on comfy_extras before you start debugging the folder path.

    Where people get burned

    • String sorting, not numeric. image_paths.sort() is lexical, so 1.png, 10.png, 2.png is the real order. Zero-pad filenames (001.png) or your "sequence" looks shuffled.
    • Subfolders need a recursive pattern. * doesn't descend; use **/*.
    • Windows paths: forward slashes in path; backslashes get eaten.
    • Incremental means incremental. Queue twice and you get two different images - that's the feature, not a caching bug. Want the same one twice? single_image plus an index.

    It earns its keep on character reference sheets for LoRA or IPAdapter runs, dataset triage before training, and img2img sweeps over a folder of old renders.

    CategoryImage/Loaders

    Inputs (8)

    NameTypeDefaultDescription
    modeCOMBO3 options: single_image, incremental_image, random
    seedINT00–18446744073709550000
    indexINT00–150000
    pathSTRING
    patternSTRING*
    allow_RGBA_outputCOMBO2 options: false, true
    filename_text_extensionoptCOMBO2 options: true, false
    load_exifoptCOMBO2 options: true, false

    Outputs (5)

    NameTypeDescription
    imageIMAGE
    filename_textSTRING
    widthINT
    heightINT
    promptSTRING