Nodes/comfyui_imgtools/Load Image with Caption (rholdorf)
ComfyUI Node

Load Image with Caption (rholdorf)

Load Image, but the .txt caption comes along for free

By rholdorf·Created 8 months ago·Updated 3 days ago· 0
Load Image with Caption (rholdorf)
    • image
    • mask
    • caption
    image

    ComfyUI's built-in Load Image is great, but it throws away the thing you often actually want: the caption. This node is Load Image plus a third output - the sidecar .txt caption that lives next to the image with the same base name. Drop in an image and you get the same image and mask outputs you're used to, plus a caption string, all from one node.

    How it works

    Same dropdown-plus-upload pattern as the built-in node. The caption read is the standard LoRA-pair convention: look for <name>.txt next to <name>.png in the same folder and return its contents as UTF-8. No .txt? Empty string, not an error - matching how the pack's other loaders behave, because unlabelled images are normal in real datasets.

    The nicest touch is the upload pair (.png + .txt) button this node adds. Multi-select both files in the file dialog (Cmd/Ctrl+click) and they upload together. If ComfyUI has to rename your image because input/ already contains that filename, the .txt is renamed to match - otherwise the pair silently desyncs and your caption comes back empty, which is exactly the footgun this button exists to prevent.

    One more detail in the mechanism: the node's cache check hashes both the image and the caption file, so if you edit the .txt while the image is unchanged, the node still re-runs. It's the small thing that means caption corrections actually propagate through your workflow.

    Inputs and outputs

    Input: image (a combo of files in input/, plus the upload button). Outputs: image, mask, caption - the caption being a plain STRING you can wire into anything that takes text.

    Where it fits

    Single-image workflows that want the caption along: LoRA caption QA, img2img where the prompt comes from the image's own description, or anywhere "the workflow should know what this image is." Wire the caption output into a CLIP Text Encode and the prompt writes itself from the sidecar file. If you need the whole folder at once, use the pack's Load Images with Captions from Dir instead - same convention, list semantics.

    Install

    Part of the small comfyui_imgtools pack by rholdorf. Install once, get all 11 nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/rholdorf/comfyui_imgtools
    

    Restart ComfyUI. Or search "rholdorf" in ComfyUI Manager. No build step, no extra dependencies - it runs on the torch/numpy/Pillow ComfyUI already ships. Young, low-star solo pack: MIT, short readable code, no network calls, no model downloads. The upload-pair button lives in web/, so a browser refresh picks up JS changes; Python changes need a restart.

    Categoryrholdorf/image

    Inputs (1)

    NameTypeDefaultDescription
    imageCOMBO1 options: example.png

    Outputs (3)

    NameTypeDescription
    imageIMAGE
    maskMASK
    captionSTRING