Set Image Metadata
Tag an image tensor so Save Image (Metadata) remembers
- image
- IMAGE
The middle step of this pack's party trick. Save Image (Metadata) will happily write whatever you type into its box - but retyping the same string into every save is dumb. Set Image Metadata attaches the string to the image tensor itself, so it rides through the workflow and lands in the save automatically.
That's the workflow pattern worth internalizing: Load Image (Metadata) → do stuff → Set Image Metadata → Save Image (Metadata). The metadata starts in the file, gets carried as a string, gets re-attached to the tensor, and ends up back in a new file - without parallel string plumbing running alongside the pixels.
How it works
setattr(image, "_metadata", metadata). That's the whole mechanism: the string becomes a Python attribute on the tensor object, and the node returns the same tensor, pixels untouched. No file I/O, no pixel changes - the tensor is just a courier. The attribute is invisible to every other node in ComfyUI (which is why the pack also ships Get Image Metadata to read it back), and it only matters when the image reaches a save node that knows to look.
Inputs
image- any IMAGE tensor.metadata- a STRING, multiline box. Want structure? You serialize it to JSON yourself; the node stores whatever string you give it, verbatim.
The two real gotchas
- It mutates the tensor in place. The attribute is set on the shared object, not a copy. If the same tensor fans out to two different Save nodes, both see the metadata. Usually harmless - but if you want different notes on different saves, don't share that wire; set metadata on separate branches instead.
- The ride is fragile. Anything downstream that rebuilds the tensor - a resize, a batch op, a VAE round-trip, a
torch.cat- drops the attribute, and the save silently falls back to "no custom metadata." Keep Set as close to Save as you can, and when in doubt, just type the metadata into Save's box instead.
Installing
ComfyUI Manager, search "Metadata Tools", install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/0nikod/ComfyUI-Metadata-Tools
Restart afterward. One trap in the README: its clone snippet reads dniko0/ but the repo is 0nikod/ - copy the corrected URL above or you'll 404. Only declared dependency is Pillow (already bundled with ComfyUI); no models, no heavy install.
Why bother
Mainly so you can chain the pack: pull an image's metadata out with Load, edit it as a string, Set it back, and let Save write the edited version. It also makes downstream saves repeatable - wire the same tensor into a batch of Save nodes and they all inherit the same notes without you touching each box.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| metadata | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |