Nodes/ComfyUI-XJNodes/Save Image With Metadata
ComfyUI Node

Save Image With Metadata

The saver that stuffs your prompt, workflow and notes into the file

By alexjx·Created 10 months ago·Updated 4 months ago· 0
Save Image With Metadata
  • images
  • file_paths
output_path
filename_prefixComfyUI
number_padding5
filename_delimiter_
filename_modeprefix_number
extension
quality100
dpi300
overwrite_existingfalse
optimizefalse
lossless_webpfalse
embed_workflowtrue
metadata

ComfyUI's default Save Image already embeds the prompt and workflow into PNGs, so why would you want another saver? Because the default one gives you almost no control: fixed filename pattern, fixed output folder, PNG only. XJSaveImageWithMetadata is the version for people who actually care about their archive - it's the author's take on WAS Node Suite's famous image saver, with filename tokens, six output formats, custom metadata, and full control over numbering.

The README is upfront that the pack is "primarily for personal use," but this is one of the nodes where that personal itch produced something broadly useful. If you save images to organize, re-find, and re-load them, this is the node in the pack you'll keep coming back to.

How it works

On save, it writes the image with embedded metadata: PNG/TIFF/BMP get their prompt and workflow in PNG text chunks, WebP tucks it into EXIF, and any custom string you feed into the metadata input goes into a dedicated xj_metadata key (PNG) or EXIF UserComment (JPEG/WebP). That custom key is what the pack's Load Image With Metadata node knows how to pull back out - the pair is a proper round-trip.

The filename machinery is the fun part. Beyond the usual counter, it supports tokens in filename_prefix and output_path: [time], [time(%Y-%m-%d)], [hostname], [user], [cuda_device], [cuda_name]. So [time(%Y%m%d)]/[user]_[cuda_name] gives you organized, self-describing folders like 20260816/gabe_rtx4090_00001.png. There's also a choice of three filename orders, and overwrite_existing off means it always finds the next free number rather than clobbering.

The inputs that matter

There are a lot of knobs; a beginner only needs a few:

  • images - the IMAGE batch to save.
  • filename_prefix - base name (tokens allowed). Default ComfyUI.
  • extension - png, jpg, jpeg, webp, bmp, or tiff. PNG is the metadata-safe default.
  • quality and dpi - for lossy formats and print/archive metadata.
  • metadata (optional) - a free-form string to embed alongside the workflow.

The two modes are worth a mention: filename_mode swaps between prefix_number (ComfyUI_00001.png), number_prefix, and number_only (a single global counter shared across prefixes, handy for one giant sequential archive). Optional toggles: embed_workflow (on by default), optimize, lossless_webp.

Output is a single file_paths output - a list of the full paths of everything it wrote, so a downstream node or log can reference them. It's an output node (the is_output_node flag is true), so it also shows its saves in the UI.

Installing it

Part of ComfyUI-XJNodes, installed once:

cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-XJNodes

then restart ComfyUI, or search ComfyUI-XJNodes in ComfyUI Manager. No models, no extra dependencies beyond ComfyUI's own Pillow/torch stack.

Common issues

JPEG is the trap: it has no PNG text chunks, so your prompt/workflow metadata goes in EXIF, and JPEG conversion also forces RGB (no alpha). If you need lossless round-trips, stick with PNG. And number_only mode scans the folder for existing numbered files to compute the next counter - if you mix prefixes and formats in the same directory, the scan can pick up files this node didn't write. That's a quirk, not a bug; keep archives tidy and it behaves.

CategoryXJNodes/image

Inputs (14)

NameTypeDefaultDescription
imagesIMAGE
output_pathSTRING
filename_prefixSTRINGComfyUI
number_paddingINT51–10
filename_delimiterSTRING_
filename_modeCOMBOprefix_number3 options: prefix_number, number_prefix, number_only
extensionCOMBO6 options: png, jpg, jpeg, webp, bmp, tiff
qualityINT1001–100
dpiINT30072–2400
overwrite_existingBOOLEANfalse
optimizeoptBOOLEANfalse
lossless_webpoptBOOLEANfalse
embed_workflowoptBOOLEANtrue
metadataoptSTRING

Outputs (1)

NameTypeDescription
file_pathsSTRING