Nodes/Image Processing Suite for ComfyUI/Load Image and Extract Prompt
ComfyUI Node

Load Image and Extract Prompt

Load a PNG and get its prompt back out of the metadata

By marcoc2·Created 2 years ago·Updated 5 months ago· 1
Load Image and Extract Prompt
    • image
    • mask
    • prompt
    image

    Load Image and Extract Prompt is the "reuse your own work" node. You load an image you generated earlier - one that has ComfyUI metadata embedded - and it hands you back the image, an alpha-derived mask, and the prompt that made it, all in a single pass. Remember that image from last week that you liked but never saved the prompt for? This is how you pull it out of the file.

    It works because ComfyUI bakes the entire workflow into the PNG by default - the KB's ecosystem essay calls embedding the workflow JSON in the output image a community norm, and it's exactly what this node exploits. The loader opens the file, converts it to a standard IMAGE tensor, reads the embedded metadata, and runs a heuristic to find the "main" positive prompt: it looks for sampler-class nodes in the embedded graph, traces their positive input back to the CLIPTextEncode that feeds it, and falls back to scanning all CLIPTextEncode nodes if that trace fails. If the image was made in A1111 instead, it grabs the first line of the parameters block. Same mechanism the whole pack uses for its dataset-prep nodes, so once you understand it here, the folder variants behave the same way.

    The outputs are the useful part. image is the loaded tensor. mask is derived from the alpha channel and inverted - transparent areas come out as white (1.0) and opaque as black, which is the convention mask-conditioning nodes expect; a PNG with no alpha just gets a 64×64 zero mask. prompt is the extracted string, ready to wire into a CLIPTextEncode.

    The realistic gotchas are about expectations. The extraction is heuristic, not a parser: if the workflow used SDXL's dual text encoders it'll grab whichever positive it finds, and if a sampler's positive isn't wired the way the heuristic expects, you might get an empty or wrong string. Images saved with metadata stripped (or exported from a viewer that wipes it) return an empty prompt - there's no way to resurrect what was never written to disk. And the image input is the standard ComfyUI file dropdown from the input folder, with an upload option - so unlike the path-string loaders in this pack, you don't type a path here.

    Where you'll actually reach for it: re-prompting your own library, and as the single-image sibling of FolderImageMetadataByName, which does the same extraction across a whole folder. Install via ComfyUI Manager (search "AnotherUtils") or clone https://github.com/marcoc2/ComfyUI-AnotherUtils into custom_nodes and restart. No extra dependencies - everything it needs is ComfyUI core.

    CategoryAnotherUtils/loaders

    Inputs (1)

    NameTypeDefaultDescription
    imageCOMBO1 options: example.png

    Outputs (3)

    NameTypeDescription
    imageIMAGE
    maskMASK
    promptSTRING