Nodes/ComfyUI McKlinton Pack — Mask Node/Save Text/Image Arrays to Files
ComfyUI Node

Save Text/Image Arrays to Files

Save a batch of prompts and images to disk, filenames intact

By McKlinton2·Created about a year ago·Updated about a year ago· 6
Save Text/Image Arrays to Files
  • images
    root_directory
    prefix
    texts
    filenames
    image_formatpng
    quality95

    The McKlinton Pack's save node (category McKlinton/save) does one boring thing that's awkward to do otherwise: write a whole batch of strings and/or images out to disk, each under its own filename, in one shot. No per-item save nodes, no CSV, no mangled names. It's the return address for the pack's batch pipeline - load a folder of Virt-A-Mate snapshots, process them, write the results back in the same layout.

    It's an output node, which means it has no outputs at all - it terminates a graph branch and writes files. That's it.

    What goes in

    Two required inputs, three optional:

    • root_directory - where files land. Created automatically if it doesn't exist.
    • prefix - a string prepended to every saved filename. This is your overwrite insurance: dump processed results into the same folder as the originals with prefix = "out_" and nobody collides.
    • texts - a string (wired from another node, e.g. the Mask Node's prompt output) or a list of strings to write as .txt files.
    • filenames - the names to save them under. The pack's LoadFilteredImageBatch hands you exactly this shape, and the two nodes are clearly designed to sit opposite each other.
    • images - a batched IMAGE tensor to write out.
    • image_format (png default, or jpg/jpeg/webp) and quality (1–100, default 95).

    How it works

    For text: it pairs texts with filenames position by position, strips any path components from the name (a small security nicety), applies the prefix, appends .txt if the name lacks it, and writes UTF-8. For images: it walks the batch, and here's the handy bit - if you give it fewer filenames than images it cycles them (a, b, a, b…), and if you give it more it truncates. So one filename can stamp a whole series, or the list can map one-to-one. Extensions get stripped and replaced with your chosen format, and quality is respected for jpg/jpeg/webp (PNG ignores it - that's a PIL thing, not a bug).

    Both text and image saving run in the same node when you wire both - one output node, one run, everything on disk.

    Install

    Same pack, same path:

    cd ComfyUI/custom_nodes
    git clone https://github.com/McKlinton2/comfyui-mcklinton-pack
    # restart ComfyUI
    

    Or via ComfyUI Manager, searching the pack title. Dependencies are just torch, numpy, and Pillow - all present in any ComfyUI install. (The pack's requirements.txt also lists three OpenCV variants; that's bloat, and you don't need any for this node.)

    Where people get burned

    • No filenames means no files, silently. The node only writes when filenames is connected - texts alone, or images alone, just runs and does nothing while printing "Saved 0 files." The most common bug is forgetting the names input, then hunting for files that were never created.
    • Text/filename length mismatch is a hard error. If you feed three prompts and two names, it raises a ValueError and the run dies. Images, by contrast, tolerate any count via cycling - the two behaviors are inconsistent, and it catches people out.
    • Names are sanitized to basenames. A filename with a path in it gets stripped down, which is good for safety but means you can't use this node to write into subdirectories by putting a path in the name. Use root_directory for structure instead.
    • PNG ignores quality - drop it for lossless output, and mind that RGBA input tensors will not save as you expect; the node assumes plain RGB.

    The honest verdict: as a generic batch saver it's a little rigid, but for the pack's own loop - take SnapshotAnimator's folder, run a batch through the graph, write the results back with names and prompts intact - it's exactly the missing bookend.

    CategoryMcKlinton/save

    Inputs (7)

    NameTypeDefaultDescription
    root_directorySTRING
    prefixSTRING
    textsoptSTRING
    filenamesoptSTRING
    imagesoptIMAGE
    image_formatoptCOMBOpng4 options: png, jpg, jpeg, webp
    qualityoptINT951–100

    Outputs (0)

    No outputs