Nodes/ComfyUI-YCNodes/Load Images From Folder YC
ComfyUI Node

Load Images From Folder YC

Load a whole folder of images — single, batch, random, or stepping through one by one

By yichengup·Created 2 years ago·Updated 4 months ago· 47
Load Images From Folder YC
    • image
    • filename
    path_type
    mode
    seed0
    image_index0
    folder_name
    custom_pathC:/Users/Pictures
    labelbatch 001
    output_filename
    allow_RGBA
    image_pattern*.png;*.jpg;*.jpeg;*.webp

    ComfyUI's built-in Load Image wants one file from its dropdown, which is maddening when you're trying to process a directory of frames or a batch of crops. Load Images From Folder YC fixes the actual complaint: point it at a folder and it pulls images in single, batch, incremental, or random mode, and hands you the filename alongside so you can keep track of what you're looking at.

    The killer feature is incremental. You set a label (default "batch 001"), and every time the graph runs, it advances to the next image in the folder, wrapping around at the end. No manual index bumping. That's the difference between "run 40 images by hand" and "queue the workflow 40 times and check the results later." Pair it with a batch-processor or an upscaler and you have a poor man's batch pipeline.

    How it works

    It scans the target directory for files matching image_pattern (default *.png;*.jpg;*.jpeg;*.webp, semicolon-separated), sorts them, and then the mode decides what happens:

    • single - load the file at image_index.
    • incremental - load the next one each run, keyed to your label. Change the path or pattern and the index resets.
    • random - pick one using seed, so you can reproduce a pick.
    • batch - load all matching images into one batched tensor at once.

    path_type picks the source: input_dir (your ComfyUI input folder, with folder_name letting you choose a subfolder, including <root>), or custom_path for an arbitrary absolute path. output_filename toggles whether the filename output carries a value, and allow_RGBA keeps the alpha channel instead of flattening.

    Outputs

    image (IMAGE) and filename (STRING). In batch mode the filename output is all names joined with semicolons, which is rough but readable. The filename is also cached per-label internally, so it survives even when you turn the output off.

    Install

    From the ComfyUI-YCNodes pack. ComfyUI Manager → search "ComfyUI-YCNodes", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yichengup/ComfyUI-YCNodes
    

    Restart ComfyUI. Only standard deps (torch, numpy, pillow, opencv-python, scipy), no models to download.

    Where people get burned

    Three traps, all real. First: batch mode does a torch.cat across all images, so if your folder mixes resolutions, it errors out. Sort by size or normalize first. Second: allow_RGBA produces 4-channel tensors, and most ComfyUI image nodes expect 3 - leave it off unless you genuinely need alpha. Third: the default custom_path is a Windows path (C:/Users/Pictures); on Linux that folder won't exist, and the node silently returns a 64×64 black image as a sentinel rather than erroring. That silent black frame is the kind of thing that wastes an hour, so check your path. Also note incremental state lives per-label, not per-folder - two workflows sharing a label will step on each other.

    CategoryYCNode/Image

    Inputs (10)

    NameTypeDefaultDescription
    path_typeCOMBO2 options: input_dir, custom_path
    modeCOMBO4 options: single, incremental, random, batch
    seedINT00–18446744073709550000
    image_indexoptINT00–99999
    folder_nameoptCOMBO2 options: <root>, 3d
    custom_pathoptSTRINGC:/Users/Pictures
    labeloptSTRINGbatch 001
    output_filenameoptCOMBO2 options: true, false
    allow_RGBAoptCOMBO2 options: false, true
    image_patternoptSTRING*.png;*.jpg;*.jpeg;*.webp

    Outputs (2)

    NameTypeDescription
    imageIMAGE
    filenameSTRING