Nodes/ComfyUI_Lam/保存图像(内循环用)
ComfyUI Node

保存图像(内循环用)

Save images mid-loop and get the file paths back

By yanlang0123·Created 2 years ago·Updated 11 days ago· 77
保存图像(内循环用)
  • images
  • custom_prompt
  • 图像
  • 图像地址
filename_prefixComfyUI

SaveImageLam (保存图像(内循环用), "save image, for inner loops") is the save counterpart to the pack's PreviewImageLam, and it fixes the same fundamental problem. ComfyUI's stock SaveImage is an output node - the moment it runs, that branch is terminal. In a loop workflow you often want to save every iteration and keep the graph running. This node saves to your output directory, passes the images through, and hands you the saved file paths as a string. That last bit is the feature stock SaveImage doesn't have.

Use it in exactly the situation the name describes: an inner loop (the pack's ForStart/ForEnd, DoWhileStart/DoWhileEnd) producing frames or variations that should each land on disk as they're generated. Because it isn't terminal, the loop can continue; because it returns paths, a downstream video encoder, upscaler, or external tool can pick up the files it just wrote without re-finding them.

How it works

It subclasses ComfyUI's SaveImage, so the writing machinery is the battle-tested core: files go to ComfyUI/output/<filename_prefix>_00001_.png with standard counter naming and PNG metadata embedded. The differences are deliberate: OUTPUT_NODE = False (non-terminal), RETURN_TYPES = ("IMAGE","STRING") (pass-through plus paths), and the paths come back as a single comma-joined string covering the whole batch. There's also an optional custom_prompt DICT input: give it key/value pairs and they're written as PNG metadata instead of the default workflow dump - useful when you want clean, predictable metadata tags rather than a full prompt blob.

Inputs and output

  • images - the IMAGE to save.
  • filename_prefix - output filename stem (default ComfyUI).
  • custom_prompt - optional DICT of metadata key/value pairs.
  • Outputs: 图像 (the same IMAGE) and 图像地址 (comma-joined save paths as a STRING).

Install

In yanlang0123/ComfyUI_Lam - Manager search "ComfyUI_Lam", or:

cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam

restart. It lives in the image category. No models, no deps beyond ComfyUI's own save code - skip the pack's install.bat if you're only using the image utilities.

Gotchas

The comma-joined path string is the thing to remember: for a batch of 4 it's path1,path2,path3,path4, so a downstream node that expects a single path needs to split on commas (or you feed it single-frame batches). Also, since it's not an output node, ComfyUI won't show its results in the "outputs" panel the way stock SaveImage does - files land on disk, but the graph treats it as mid-pipeline. And like any in-loop writer, it's a disk write per iteration, so for a 500-frame loop that's 500 PNGs; mute it once you're done debugging. Right tool for the job - just know the job is "save while you keep going," not "save and stop."

Categoryimage

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE
filename_prefixSTRINGComfyUI
custom_promptoptDICT

Outputs (2)

NameTypeDescription
图像IMAGE
图像地址STRING