Nodes/comfyui-spawner-nodes/Read Image Metadata
ComfyUI Node

Read Image Metadata

Read the metadata ComfyUI and A1111 actually embed in a PNG

By spawner1145·Created about a year ago·Updated 11 months ago· 2
Read Image Metadata
    • metadata_json
    image

    The whole "drag a PNG back into ComfyUI and the workflow comes back" trick works because the image is carrying text: ComfyUI writes a workflow chunk and a prompt chunk into the PNG's text metadata, A1111 writes a flat parameters string, SillyTavern packs character cards into a chara chunk. ImageMetadataReader is the node that reads all of it out of a file and hands it to you as one JSON string.

    Here's the first thing to know, because it trips everyone: the input is a file selector, not an IMAGE socket. The node lists the files in your ComfyUI/input/ directory and reads the chosen one straight off disk. You can't feed it a loaded image tensor - which is exactly right, because a tensor has already been decoded and its metadata stripped. If you want the embedded workflow from an image you generated, the file has to be in input/ (drop it there or upload it), then pick it from the dropdown.

    What comes out, one metadata_json string, pretty-printed:

    • filename, width, height - the basics.
    • exif - EXIF tags, decoded to names (skipping thumbnails). Read via piexif.
    • png_text - the good stuff, read via pypng: every tEXt/iTXt chunk, with prompt and workflow chunks parsed as JSON and everything else (A1111's parameters, SillyTavern's chara) decoded as text.

    That last line is the killer feature. This node is how you extract the A1111 prompt + settings from a PNG you found, or pull a SillyTavern character card out of an image for a roleplay workflow. The pack's own example workflows do exactly this: read a webui PNG, extract png_text.parameters with json_process, and decode the chara card with TextEncoderDecoder. It's a metadata extraction front end for the LLM-in-ComfyUI crowd.

    Caveats, honest version: it only reads PNG text chunks, so JPEG/WebP files give you EXIF (or "No EXIF") and no png_text - and if an image host re-encoded your file, the chunks are gone entirely, which no reader can restore. The error handling is graceful (you get an error object in the JSON rather than a crash), but a missing chunk reads as "No PNG text chunks found." rather than a hard failure.

    Install

    ComfyUI Manager → search comfyui-spawner-nodes → install → restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/spawner1145/comfyui-spawner-nodes
    

    Deps: piexif and pypng (the actual libraries doing the reading) plus xmltodict. All pure Python, no models. README is a stub; the author (spawner1145) is a Chinese-speaking dev also known for a Wan2.1 SD extension.

    Troubleshooting

    • File doesn't appear in the dropdown - it's not in ComfyUI/input/. Upload it in the UI or copy it there, then refresh.
    • png_text is "No PNG text chunks found." - the file genuinely has no text chunks (stripped by a re-encode, or saved by software that never wrote them). Nothing to recover; see image-io-metadata for why.
    • prompt/workflow show as strings, not objects - some files carry malformed or partial JSON, and the node falls back to raw text. json_process can still dig through it.
    • You expected an IMAGE input - it's a file picker. That's the whole design; a decoded tensor has no metadata left to read.
    Categoryspawner/utils

    Inputs (1)

    NameTypeDefaultDescription
    imageCOMBO1 options: example.png

    Outputs (1)

    NameTypeDescription
    metadata_jsonSTRING