Nodes/ComfyUI-Prompt-Gallery/🎨 保存到画廊
ComfyUI Node

🎨 保存到画廊

Save every generation into your prompt gallery automatically

By Lotus0614·Created 5 months ago·Updated 7 days ago· 28
🎨 保存到画廊
  • images
    prompt_string
    prefixprompt_gallery/AG

    The point of a prompt library is that you keep the good stuff. This is the node that does the keeping. Drop it after your VAE Decode, feed it the image and the prompt text that produced it, and it writes the PNG into ComfyUI's output folder, registers it in the gallery's image index, and matches it against your saved prompts - auto-setting a cover image from the first frame if a prompt has none. From then on, that image is browseable in the gallery's history view with its full generation metadata.

    In the wider workflow it's the bookkeeping half of the loop: PromptsSelector assembles a prompt from the library, SaveToGallery puts every result back into the library with its context. Build that loop and you stop losing good seeds and their prompts to the void of an unlabeled output folder.

    How it works

    Mechanically it's a smarter Save Image. The prefix input is a little template: the last path segment is the filename prefix, everything before the final / is a directory relative to output. Both support strftime formatting. So:

    • prompt_gallery/AGoutput/prompt_gallery/AG_1752724800000_0.png
    • gallery/%Y/%m/portraitoutput/gallery/2026/07/portrait_1752724800000_0.png
    • AGoutput/AG_1752724800000_0.png

    Timestamps are shared across a batch, and a random suffix guards against same-millisecond collisions - the source is careful about that.

    The PNG itself carries the whole reproducibility story, same convention the ecosystem runs on: it embeds the prompt chunk (the graph that ran) plus a prompt_gallery chunk holding your prompt string and your extra_pnginfo. The image is the project file. Drag it back into ComfyUI and the workflow reconstructs.

    Then comes the async part. Saving to disk happens synchronously - that's the work you can't lose. The index registration, prompt matching and cover assignment are queued to a background thread so the workflow returns immediately instead of blocking on a substring scan across every saved prompt.

    The inputs that matter

    • images (required) - the IMAGE tensor from your VAE Decode.
    • prompt_string (required) - the prompt text. It is not optional. The node raises a ValueError if you leave it empty, and that's the single most common way people trip over this node.
    • prefix (optional) - directory + filename template above. Default prompt_gallery/AG.

    No outputs - it's an output node, the last stop on the line.

    Install

    Same pack-wide steps as the other nodes. ComfyUI Manager → search "Prompt Gallery", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Lotus0614/ComfyUI-Prompt-Gallery
    cd ComfyUI-Prompt-Gallery
    pip install -r requirements.txt
    

    Windows portable: ..\..\python_embeded\python.exe -m pip install -r requirements.txt. Deps are light - Pillow plus pyahocorasick for faster bulk cover matching (falls back gracefully). Restart ComfyUI and hard-refresh the browser afterwards; this pack's frontend caches hard.

    Common issues

    • "SaveToGallery 需要连接 prompt_string" - you skipped the prompt string. Wire it from PromptsSelector.prompts_string or any string output holding the final prompt.
    • Image saved but not in the gallery yet - indexing runs in the background; refresh the gallery after a moment. Also confirm prefix resolves to a valid relative path under output.
    • Old images have no covers - open gallery Settings → 图库设置 and run "auto-match covers". It only touches prompts that have none, but on a large library it can take a while - that's what pyahocorasick is for.
    • UI looks stale after an update - hard refresh or clear the site cache; old assets stick around otherwise.
    • Back up user/default/prompt_gallery/ and your output subfolders before migrating or upgrading ComfyUI.
    Category🎨 Prompt Gallery

    Inputs (3)

    NameTypeDefaultDescription
    imagesIMAGE
    prompt_stringSTRING
    prefixoptSTRINGprompt_gallery/AG

    Outputs (0)

    No outputs