This is the Comfyui version of a personal project I started last year (2024) with GPT/Claude, as a shell/commandline tool to add tags to ANY images on my computer.
Why, you say ? READ THE WHOLE STORY (or not, your call)
Or at least that's the theory of it.
These custom nodes for ComfyUI will allow you to READ and WRITE XMP METADATA to images. A sidenote though, this is not designed to handle image generation datas, there's already plenty of nodes for that.
- Use the "Write XMP Metadata (Lossless)" node
- Enter the path to your image in
input_image_path - Add your tags as comma-separated values in
metadata(e.g., "landscape, sunset, ocean") - Run the node
- The tagged image will be saved in a
"tagged"subfolder in the same directory as the original, unless you specify a custom path
- Connect your image generation output to the "Write XMP Metadata" node
- Add your metadata in the
metadatafield - Choose a format mode (Smart format is recommended)
- Run the node
- The image with metadata will be saved in the output directory
- Use the "Read XMP Metadata" node
- Enter the path to your image in
image - Set
metadata_typeto "Subject" to extract tags - Run the node
- The tags will be returned as a string
The metadata input can be either:
- A simple string with comma-separated values (e.g., "landscape, sunset, ocean")
- A JSON object with a "tags" key and other custom fields:
{ "tags": ["landscape", "sunset", "ocean"], "author": "John Doe", "description": "Beautiful sunset at the beach" }
If you had similar needs to use prompt keywords and other datas from AI generated images to use as search tags, I can't recommend anything but the amazing Diffusion Toolkit it's awesome, TRY IT IT'S GREAT
Picasa was nice too with tags, back in the days... a bit limited though. A bit dead too, long ago x) Sad. And Lightroom is... meh. Nah.
-
Clone this repository into the
custom_nodesfolder of your ComfyUI installation:git clone https://github.com/tetsuoo-online/comfyui-too-xmp-metadata.git -
Make sure ExifTool is installed:
- Download it here
- rename the EXE (usually called "exiftool(-k).exe") to
exifTool.exethen put it to the package root folder.
- ComfyUI
- ExifTool
- PIL/Pillow
- NumPy
-
Inputs:
image: Path to the image filemetadata_type: Type of metadata to extract (Subject, Description, Create Date, Modify Date, or Custom)custom_metadata: Custom metadata field to extract (when metadata_type is set to "Custom")console_debug: Enable detailed debug messages
-
Outputs:
- The extracted metadata value as a string
-
Inputs:
input_image_path: Path to the original image filemetadata: Metadata to add (string or JSON)output_dir: (Optional) Custom output directoryconsole_debug: (Optional) Enable detailed debug messages
-
Outputs:
- Path to the output image file
-
Features:
- Lossless operation: Preserves the original image without recompression
- Format preservation: Keeps the original file format (PNG, JPG, WEBP, etc.)
- Date preservation: Maintains the original creation and modification dates
- Safe operation: Avoids processing loops by detecting files in "tagged" folders
-
Inputs:
image: Image tensormetadata: Metadata to add (string or JSON)format_mode: Format selection (Preserve format, Smart format, Force PNG, Force JPG)input_image_path: (Optional) Path to the original image for name and format referenceoutput_dir: (Optional) Custom output directoryconsole_debug: (Optional) Enable detailed debug messages
-
Outputs:
- Path to the output image file
-
Features:
- Smart format detection: Can automatically select the best format based on image content
- Format options: Can force specific formats or try to preserve the original format
- Integration with ComfyUI workflow: Works directly with image tensors from other nodes
🔴 IMPORTANT NOTE: For now, only the Write LOSSLESS node will keep existing metadatas (see image example below). The normal Write XMP Metadata on the other hand re-formats the image so if anything was in there it will be PURGED before adding the new metadata, so please pay attention to that.
1.1.0
- existing metadatas no longer overwritten with Losless node 1.0.0
- first release
- add subfolders support maybe. It sounds dangerous, but I need it~
- add tooltips
- Special thanks to Claude Sonnet AI x) Manus AI got me started despite the poor service, ChatGPT helped too but Claude was definitely the best
- Thank you to Starnodes2024 for the inspiration

