Save Image with Caption (rholdorf)
Save PNGs with matching captions — build a LoRA dataset in one pass
- images
The built-in SaveImage writes a PNG. If you're building a LoRA training set, you need a PNG and a matching .txt caption with the same base name in the same folder - the standard layout every trainer (ai-toolkit, kohya, OneTrainer) and every loader in this pack expects. This node is SaveImage with that second file added: it writes your image with normal ComfyUI metadata and drops a UTF-8 .txt caption next to it, same stem, so the pair stays in sync by construction.
How it works
It mirrors the built-in SaveImage closely - same get_save_image_path prefix/counter logic, same _NNNNN_ batch suffix, same output folder - so you won't be surprised by where files land. The PNG carries the standard workflow metadata unless you run ComfyUI with --disable-metadata, and the caption file is written as UTF-8, which matters because non-ASCII captions are normal in real datasets and other tools read them inconsistently.
Inputs and outputs
images- what you're saving. A batch writes one.png+.txtpair per image.caption- multiline string widget, the caption text.filename_prefix- default "ComfyUI"; supports the same formatting as built-in save nodes, like%date:yyyy-MM-dd%or%Empty Latent Image.width%.caption_in- optional input-only string. When connected it overrides the widget value, which is how you pipe an upstream caption (say, from the pack's Load Image with Caption, or from a text-generation node) into the save.
Outputs: none - it's an output node, the terminal point of a branch.
Where it fits
The obvious loop: load a reference image and its caption with Load Image with Caption, generate variations, save them back out with this node - and the folder you've produced is directly consumable by a trainer or by the pack's Load Images with Captions from Dir for QA. It's the third corner of the pack's image+caption convention, and the one that makes the convention self-consistent: save pairs, load pairs, no manual .txt renaming in between.
One honest limitation: the caption is a single string per batch, written to every image in it. If you need different captions per image, feed each through separately or drive caption_in per item upstream. For the common case - "here's one caption, save the batch" - it just works.
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's Pillow, which ComfyUI already ships. Young, low-star solo pack: MIT, short readable code, no network calls, no model downloads. JS changes under web/ need only a browser refresh; Python changes need a restart.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | The images to save. | |
| caption | STRING | Caption written as a UTF-8 .txt file alongside each image (same base name). | |
| filename_prefix | STRING | ComfyUI | Prefix for the saved files. May include formatting like %date:yyyy-MM-dd% or %Empty Latent Image.width%. |
| caption_inopt | STRING | — |
Outputs (0)
No outputs