Nodes/ComfyUI-Metadata-Inspector/Extract PNG Metadata
ComfyUI Node

Extract PNG Metadata

The metadata node that digs prompts out of JPEGs, not just PNGs

By TakkunRed·Created 5 months ago·Updated 5 months ago· 1
Extract PNG Metadata
    • metadata_json
    image_nameexample.png

    The name undersells this one. It says "PNG metadata," but the whole point of Extract PNG Metadata is that it reads anything - and it's the one node in the Metadata-Inspector suite that does the actual work. Drag a ComfyUI PNG back onto the canvas and you get the workflow, sure. But drag a JPEG you saved from Civitai or Tensor.art back, and ComfyUI shrugs. That's where this node earns its keep: it scans the file's text chunks and EXIF deeply enough to recover the prompt and generation parameters even when standard tools come up empty.

    What it actually does

    ExtractPngMetadata takes a filename, opens the image with Pillow, and dumps everything into one JSON object that comes out its single metadata_json output:

    • fileinfo - filename, last-modified date, file size, and resolution. Nice for organizing, not the reason you installed this.
    • PNG text chunks - for a ComfyUI image that's the prompt and workflow chunks (the full graph JSON that powers drag-to-reconstruct); for A1111 output it's a parameters chunk with the prompt, negative, and settings.
    • Smart JSON recovery - values get passed through a parser that regex-scans for a {...} or [...] blob and tries to json.loads it, even when the JSON is buried inside a plain-text string. If it finds the classic A1111 Steps:/Seed: layout instead, it splits it into clean lines.
    • EXIF deep scan - the interesting part for JPEGs. It walks the main EXIF tags and the Exif sub-IFD (0x8769), which is exactly where Civitai and Tensor.art hide their UserComment and ImageDescription tags. That sub-IFD pass is why this recovers data where other tools fail.

    If the file doesn't exist you don't get a crash - you get {"error": "File not found"} inside the JSON. Which, as you'll see below, is a trap, not a feature.

    The input that matters

    There's exactly one: image_name, a string that defaults to "example.png". Two ways to fill it:

    • A bare filename like my_img.png - it resolves against ComfyUI's input folder, so drop the file in ComfyUI/input and type its name.
    • An absolute path - /home/you/Pictures/img.jpg just works, which is handy for files outside the input folder.

    Installing it

    Same as any pack in this suite - clone, restart, done. No model downloads, and the dependencies list is empty; the only real dependency is Pillow, which ComfyUI already ships:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TakkunRed/ComfyUI-Metadata-Inspector.git
    

    Or search "ComfyUI-Metadata-Inspector" in ComfyUI Manager and hit install.

    Where people get burned

    • The default filename is fake. example.png doesn't exist on your machine, so your first run returns {"error": "File not found"} and the node looks broken. It isn't - type a real filename.
    • The name has to match exactly, including subfolders. If you loaded folder/img.png in the Load node, feed folder/img.png here, not img.png.
    • It only reads when you queue. Nothing happens at load time; run the graph and check the output.

    Wire metadata_json into the JSON Tree Viewer node from the same pack (or any Show Text node) to actually read the result. It's a string output, so you can also feed it to a Save Text node and keep the metadata as a file instead of squinting at the canvas.

    Categoryimage/metadata

    Inputs (1)

    NameTypeDefaultDescription
    image_nameSTRINGexample.png

    Outputs (1)

    NameTypeDescription
    metadata_jsonSTRING