Nodes/ComfyUI_StarNodes/⭐ Star Image Loader 1by1
ComfyUI Node

⭐ Star Image Loader 1by1

Feed a folder one image per run, and don't lose your place when ComfyUI restarts

By Starnodes2024·Created 2 years ago·Updated 2 days ago· 106
⭐ Star Image Loader 1by1
    • image
    • mask
    • image_path
    • current_index
    • total_images
    • remaining_images
    folder
    reset_counterfalse
    include_subfoldersfalse
    sort_byname
    reverse_orderfalse

    The classic way to process a folder one image at a time in ComfyUI is to hand-load each file into a Load Image node and re-run, which is fine for three images and soul-crushing for three hundred. Star Image Loader 1by1 is the batch-processing version: it walks a folder, serves the next image on every run, and remembers where it is between runs - the trick that makes it usable for unattended image-to-image pipelines.

    How it works

    Give it a folder path and it lists the images (jpg, png, webp, gif, bmp, tiff and friends). On each workflow run it returns the next image in line and advances a counter. The state lives in a JSON file - .star_loader_state.json - written inside the folder it's reading, which is the clever bit: the counter survives ComfyUI restarts, queue re-runs, even crashes. No state file on disk means no position memory, and that's the single most common misunderstanding about this node.

    Ordering is your call. sort_by gives name, date, size, or random; reverse_order flips it; include_subfolders digs deeper when your folder has structure. When you've hit the end, it auto-resets to the start so a long queue doesn't stall - or you flip reset_counter to jump back manually mid-run.

    The outputs that matter

    • image - the current frame. Wire it into an img2img node or a VAE encoder.
    • mask - alpha channel of the loaded image as a MASK, handy for compositing.
    • image_path (STRING) - full path of the current file; useful for a Save node that should keep original filenames.
    • current_index, total_images, remaining_images (INT) - the progress trio. Wire remaining_images into a text display or a logic gate that stops the queue when it hits zero.

    Where it fits

    The canonical use is a folder-to-folder restyle loop: Loader 1by1 → img2img chain → Save Image (with original names via image_path). Queue it up, walk away. It's also the backbone of "generate variations of every frame" workflows for video.

    Installing

    In the StarNodes pack - install Starnodes via ComfyUI Manager, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Starnodes2024/ComfyUI_StarNodes
    cd ComfyUI_StarNodes
    pip install -r requirements.txt
    

    Restart, then search star on the canvas. No models or extra dependencies.

    Common issues

    The state file is the whole game, so be deliberate about it. If you copy the folder or change its path, the node starts fresh - that's expected, but it trips people up when they move a dataset mid-run. If the same image keeps coming back, reset_counter is off and you've hit the end of the folder (it wraps around). And remember the state is keyed to the folder: two workflows reading the same folder share the counter, which can be exactly what you want or a quiet bug, depending on your setup.

    Category⭐StarNodes/Image And Latent

    Inputs (5)

    NameTypeDefaultDescription
    folderSTRING
    reset_counteroptBOOLEANfalse
    include_subfoldersoptBOOLEANfalse
    sort_byoptCOMBOname4 options: name, date, size, random
    reverse_orderoptBOOLEANfalse

    Outputs (6)

    NameTypeDescription
    imageIMAGE
    maskMASK
    image_pathSTRING
    current_indexINT
    total_imagesINT
    remaining_imagesINT