Nodes/ComfyUI-Info-Prompt-Toolkit/Referenced Image Saver
ComfyUI Node

Referenced Image Saver

Re-Save an Image With New Metadata Without Ever Re-Encoding the Pixels

By kinorax·Created 5 months ago·Updated about a month ago· 2
Referenced Image Saver
  • image_reference
  • image_info
  • image_reference
  • image_info
  • file_path
filename_suffiximage
output_dir
output_subdirnone
write_captionfalse
file_stem
caption

Re-saving an image is usually the point of no return for quality. Every re-encode of a lossy WebP or JPEG makes it worse, and the usual "save image" path goes pixels → decode → re-encode → new pixels, silently degrading the file even though you only wanted to change its metadata. IPT-ReferencedImageSaver does the thing that seems impossible at first: it takes an existing image file (via the image_reference pointer from Image Reader), copies it into your ComfyUI output directory, and rewrites the A1111 infotext metadata from image_info - without touching a single encoded pixel.

This is the node for "I generated this, saved it, and now I want the recipe attached" or "I want to reorganize outputs with correct metadata." The pixels are bit-for-bit preserved; only the metadata block changes.

How it works

It resolves the source file paths from the image_reference input(s), copies each file to the output location, and rewrites the metadata in place. Supported formats are PNG, WebP, and JPEG - all three can carry this kind of text metadata - and the source extension is preserved. Naming works like Image Saver: leave file_stem unconnected and you get automatic serial naming with filename_suffix; connect it and the file saves as <file_stem><source extension>, overwriting any existing file with that name. output_subdir can organize by date (same options as the saver), and write_caption drops a same-name .txt next to each file.

Inputs and outputs that matter

  • image_reference (required, IPT-ImageFileRef) - the source file pointer, almost always from Image Reader.
  • image_info (optional) - the metadata to write. This is the whole point; without it you're just copying files.
  • file_stem / filename_suffix - naming, exactly like Image Saver.
  • write_caption / caption - companion .txt writing.

Outputs are the updated image_reference, the written image_info (as a list), and file_path.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/kinorax/comfyui-info-prompt-toolkit.git
cd comfyui-info-prompt-toolkit
pip install -r requirements.txt

Restart, or ComfyUI Manager → "ComfyUI-Info-Prompt-Toolkit". ComfyUI 0.17.0+. No models.

Common issues

The obvious gotcha: image_reference must come from a node that produces the file pointer (like Image Reader), not a raw image tensor - wire the wrong socket and the node fails on resolution. And because the metadata is rewritten in the copied file, make sure image_info is complete before you save: unlike the pixel path, there's no re-encode to fail on, so an incomplete recipe writes quietly. Overwrite behavior with file_stem is deliberate - connected means clobber, so don't connect it if you need every run to produce a new file. For the "keep the lossy file, fix the metadata" job, this is the right tool and there isn't a stock ComfyUI equivalent.

CategoryInfo-Prompt-Toolkit/ImageInfo

Inputs (8)

NameTypeDefaultDescription
image_referenceIPT-ImageFileRefReferenced image file to copy and update without re-encoding pixels
filename_suffixSTRINGimageSuffix part of output filename
output_dirSTRINGBase output directory under ComfyUI output
output_subdirCOMBOnoneOutput sub directory format
write_captionBOOLEANfalseWrite caption txt file
image_infooptIPT-IMAGEINFOImage info or image-info list for each referenced image
file_stemoptSTRINGOptional output filename stem list; when connected, save as <file_stem><source extension>
captionoptSTRINGCaption text or caption list for each referenced image

Outputs (3)

NameTypeDescription
image_referenceIPT-ImageFileRef
image_infoIPT-IMAGEINFO
file_pathSTRING