Nodes/ComfyUI-My-Nodes/读取PNG元数据
ComfyUI Node

读取PNG元数据

Pull the workflow back out of a PNG, one chunk at a time

By Tagbliton·Created 2 years ago·Updated about a year ago· 11
读取PNG元数据
    • parameters
    • json_data
    image

    Every ComfyUI PNG is secretly a container. The pixels are the visible layer, but the file also carries text chunks with the workflow that made it - and depending on where the image came from, one of those chunks is a flat, human-readable settings string. This node is a two-output metadata reader: pick an image from your input folder, and it hands you both.

    The two outputs are the interesting part, because they map to two different metadata dialects the KB's image-io-metadata.md explains in detail:

    • parameters - the A1111/Forge dialect: a single flat string of positive prompt, negative prompt, and settings (Steps:, Sampler:, CFG scale:, Seed:, Model:, …). Useful when you want to reuse a prompt from an image someone made in Automatic1111 or Forge - or a CivitAI upload, which auto-detects exactly this block.
    • json_data - the ComfyUI workflow chunk: the editable JSON node graph. This is what lets you drag a PNG back onto the canvas and rebuild the pipeline.

    Mechanically it's simple: the node lists images in your ComfyUI input directory (with the standard upload widget), opens the chosen file with PIL, and reads the PNG tEXt chunks. What it does not do is write - its sibling "写入PNG元数据" in this pack handles that, and it's a different shape of tool.

    Why reach for it? Three honest reasons. One: you got an image from somewhere and want its generation settings without opening A1111's PNG Info tab. Two: you're building a workflow that inspects its own inputs - e.g., a batch job that reads parameters from files and feeds the prompts back into generation. Three: you want to verify whether an image even has workflow metadata before you trust the "workflow included" claim - because screenshots, JPEGs, and re-encoded images strip it all, and image-io-metadata.md has the full rundown of what kills it.

    Install: ComfyUI Manager → "ComfyUI-My-Nodes", or git clone https://github.com/Tagbliton/ComfyUI-My-Nodes into custom_nodes and restart. No special dependencies beyond what the pack's requirements.txt already pulls (numpy, requests, the pinned urllib3==1.26.20, etc.).

    Gotchas. Only PNGs - the node uses PIL's PNG text-chunk reader, so JPEG/WebP metadata is invisible to it. And don't confuse the two outputs: parameters is a string you can reuse as a prompt; json_data is a graph you could theoretically feed back to the API format - but pasting json_data into a prompt box is a mistake that produces pure garbage. It's a reader, not a loader: to actually load a workflow, drag the PNG onto the canvas, which is what ComfyUI does natively and better.

    Category我的节点/PngInfo

    Inputs (1)

    NameTypeDefaultDescription
    imageCOMBO1 options: example.png

    Outputs (2)

    NameTypeDescription
    parametersSTRING
    json_dataSTRING