ComfyUI Extension: comfyui-too-xmp-metadata
Custom nodes for ComfyUI that allow you to read and write XMP metadata to images
Custom Nodes (0)
README
Examples | Installation | Tiny node list |
</div>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.
<details> <summary><ins>Why, you say ? READ THE WHOLE STORY</ins> (or not, your call)</summary> <div> Because. I.Love.Images. Too much ! So the big idea was to add tags to images instead of yet another gigantic-painful-to-maintain database, that way you CAN'T LOSE THE TAG DATABASE ANYMORE IT'S INSIDE THE FILES !! This is genius. lol Later on, to find any image that I can't clearly remember the name of I can simply type a keyword in a pic viewer that supports XML tags, like for example <a href="https://www.xnview.com/">XnView MP</a>.<br> Or at least that's the theory of it.<br> </div> </details>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.
Examples
Adding tags to an existing image without modifying it
- 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
Adding metadata to a generated image
- Connect your image generation output to the "Write XMP Metadata" node
- Add your metadata in the
metadata
field - Choose a format mode (Smart format is recommended)
- Run the node
- The image with metadata will be saved in the output directory
Reading tags from an image
- Use the "Read XMP Metadata" node
- Enter the path to your image in
image
- Set
metadata_type
to "Subject" to extract tags - Run the node
- The tags will be returned as a string
Metadata Format
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 <a href="https://github.com/RupertAvery/DiffusionToolkit">Diffusion Toolkit</a> it's awesome, <b>TRY IT IT'S GREAT</b><br> 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.<br>
<h1><em>ANYWAY</em></h1>Installation
-
Clone this repository into the
custom_nodes
folder of your ComfyUI installation:git clone https://github.com/tetsuoo-online/comfyui-too-xmp-metadata.git
-
Make sure ExifTool is installed:
- Download it <a href="https://exiftool.org/">here</a>
- rename the EXE (usually called "exiftool(-k).exe") to
exifTool.exe
then put it to the package root folder.
Requirements
- ComfyUI
- ExifTool
- PIL/Pillow
- NumPy
Tiny node list
<h3>🟢 Read XMP Metadata</h3> This node extracts XMP metadata from an image file.-
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.
VERSIONS
1.1.0
- existing metadatas no longer overwritten with Losless node 1.0.0
- first release
TO DO
- add subfolders support maybe. It sounds dangerous, but I need it~
- add tooltips
Credits
- 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 <a href="https://github.com/Starnodes2024">Starnodes2024</a> for the inspiration