Nodes/ComfyUI-GPT4V-Image-Captioner/SanmiSaveImageToLocal
ComfyUI Node

SanmiSaveImageToLocal

Save anywhere, and save the caption next to it

By 438443467·Created 2 years ago·Updated about a year ago· 27
SanmiSaveImageToLocal
  • images
    filenameComfyUI
    file_path
    isTrue0
    generate_txtfalse
    txt_content

    ComfyUI's built-in Save Image is fine until you need to write files to a folder that isn't the output directory. This node is the escape hatch: give it an absolute file_path and it saves PNGs there, creating the folder if it doesn't exist. And it has one genuinely useful party trick - flip generate_txt on and it writes a .txt file next to each image containing txt_content. Wire the prompt output of GPT4V-Image-Captioner into that and you've got an instant caption-everything pipeline that lands image + caption.txt pairs on disk, ready for a training run.

    How it works

    It's an output node (no outputs), built on top of ComfyUI's own save machinery. If file_path is empty it just defers to the standard output folder and behaves like the built-in Save Image. Otherwise it converts each tensor to a PIL image and writes {filename}.png into your folder. If that filename already exists it appends a random 8-character suffix instead of overwriting - so you can batch-run the same filename all day and never clobber a previous save. Set generate_txt and txt_content and a same-named .txt is written alongside.

    The inputs that matter

    • images - the IMAGE tensor(s) to save.
    • filename - base name, default ComfyUI.
    • file_path - absolute destination folder. Empty = default output dir. This is the one you'll actually set.
    • isTrue - an integer flag; when it equals 2 the node skips saving entirely. That's the handshake with Samin Load Image Batch, whose isTrue output is 2 when a numbered image wasn't found. Hook them together and a missing file just gets skipped instead of writing a black image.
    • generate_txt / txt_content - the caption sidecar.

    One thing it does not do is embed workflow metadata. Core Save Image stuffs the full graph into the PNG's text chunks so you can drag the image back into ComfyUI later. This node writes a plain PNG, so keep the workflow saved separately if you want it recoverable.

    Where people get burned

    The isTrue == 2 skip check is exactly why it reads oddly - if you're testing standalone, an isTrue of 2 silently does nothing. Also note the node only ever writes PNG, regardless of the source, and there's no filename counter beyond the random suffix, so you can end up with a folder of result,3f8kq2ab.png if you don't manage names. And as with every "Sanmi Simple Node," remember the caveat: the pack was trimmed down in April 2025 to just the captioner, so on a fresh install you'll need the code from the repo's older history (Load_Image_Batch.py at commit b4487aab) to get this node back.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/438443467/ComfyUI-GPT4V-Image-Captioner
    

    Restart ComfyUI. No models, no heavy dependencies - just the pack's short requirements list. If you're building a dataset-captioning loop, this plus the captioner plus the batch loader is the whole recipe.

    CategorySanmi Simple Nodes/Simple NODE

    Inputs (6)

    NameTypeDefaultDescription
    imagesIMAGE
    filenameSTRINGComfyUI
    file_pathSTRING
    isTrueINT0
    generate_txtBOOLEANfalse
    txt_contentSTRING

    Outputs (0)

    No outputs