Nodes/ComfyUI-JPG-Metadata/Preview Image (JPG)
ComfyUI Node

Preview Image (JPG)

Drag that JPEG back in and get the whole workflow — this is the fix

By Amarillys·Created 4 months ago·Updated 3 months ago· 3
Preview Image (JPG)
  • images
    quality95

    The stock PreviewImage writes PNGs to your temp folder. That's fine, but every one of those scratch files is a few megabytes of a workflow you'll probably delete in an hour. Preview Image (JPG) does the same job in a JPEG that's typically 80–85% smaller - and then hides the entire workflow inside the JPEG's EXIF data, so you can drag that image back onto the canvas and get the full node graph restored. People have been asking ComfyUI to "save to JPG with workflow embedded" for ages; this is that feature, and this node is the scratch-disk half of it.

    What it actually does

    This is the preview sibling in the ComfyUI-JPG-Metadata pack. It behaves like the built-in PreviewImage - writes to ComfyUI/temp/, not output/, gets auto-cleaned, meant for iterating - except the output is a .jpg and the file is self-describing.

    The mechanism is neat and worth understanding because it explains both the power and the limits. When the node runs, it serializes your prompt and extra_pnginfo (which contains the workflow graph) as JSON and writes them into the EXIF UserComment tag (ID 0x9286). ComfyUI normally only puts that metadata in PNG text chunks, which is why the workflow dies the moment you export a JPEG anywhere else. Here it's deliberately re-homed into the JPEG's EXIF. Then a tiny dependency-free JavaScript EXIF parser in the pack's frontend extension reads the tag when you drop the file back into ComfyUI: if it finds a workflow key it rebuilds the full editable graph; if only prompt exists, it loads the API-format version, which will run even if it doesn't look pretty.

    Under the hood the class is just SaveImageJPG's logic pointed at the temp directory with a random _temp_ prefix - same EXIF write, same RGBA→RGB conversion (JPEG has no alpha, so transparency gets flattened), same respect for the --disable-metadata flag.

    The inputs that matter

    You'll set exactly two things, and one of them you'll probably leave alone:

    • images - the IMAGE tensor to preview. Wire in whatever you just generated.
    • quality - JPEG quality, 1–100, default 95. Crank it down when the preview is just a check and you want the file tiny; leave it at 95 if you might actually keep what you see.

    It's an output node with no outputs to wire - it just renders to the UI. The prompt and extra_pnginfo that power the drag-back are fed in as hidden inputs automatically; you don't touch them.

    Installing it

    Same story as any custom node: ComfyUI Manager → search ComfyUI-JPG-Metadata → Install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Amarillys/ComfyUI-JPG-Metadata.git
    

    Then restart ComfyUI. No model downloads, no heavy Python deps - the writing side only needs Pillow (which ComfyUI already ships) and the reader is pure JS. This is about as frictionless an install as the ecosystem offers.

    Where people get burned

    • It writes to temp/, not output/. If you preview something and go looking in your output folder, it won't be there. If you like a preview, right-click save or swap in the pack's Save Image (JPG) node before you commit.
    • The ~64 KB ceiling. EXIF UserComment holds a lot, but genuinely huge graphs can exceed it and truncate. Your 12-node SDXL workflow is fine; a 400-node monster may not round-trip.
    • Drag-back only works while the EXIF survives. Works great on the local file. Post it to Reddit or an inline Discord preview and the host re-encodes it, killing the EXIF - same re-encode trap that strips PNG metadata, just with JPEG.
    • --disable-metadata kills the feature by design. If you run ComfyUI with it for privacy, the preview is a plain JPEG.
    • The preview carries your whole prompt and graph. Same privacy footgun as PNGs: anyone with the file can read your seed, your model names, your negative prompt. Fine on your own disk; think before sharing.

    Should you reach for it?

    If you live in PreviewImage and your temp folder is a wasteland of megabyte PNGs, this is a strict upgrade - smaller files, and the accidental superpower that every scratch preview is a loadable workflow. If you never re-open your own previews and don't care about disk, the built-in node still works. But once you've dragged a JPEG back and watched the graph reassemble, the built-in one feels like leaving money on the table.

    Categoryimage

    Inputs (2)

    NameTypeDefaultDescription
    imagesIMAGEThe images to preview.
    qualityINT951–100JPEG quality (1-100).

    Outputs (0)

    No outputs