Nodes/Pseudocomfy/Save Image with Embedded Masks
ComfyUI Node

Save Image with Embedded Masks

Render once, keep the masks alive in the PNG

By Pseudotools·Created 2 years ago·Updated 19 days ago· 4
Save Image with Embedded Masks
  • imgs
  • msks
    filename_prefixpseudocomfy

    Normal ComfyUI saves the image and throws the masks away. This node is the exception that the whole Pseudocomfy pipeline is built around: it saves your rendered image and bakes every mask into the PNG's metadata, so the masks survive the round-trip back to the Rhino plugin that started the whole thing.

    Think about what that means in practice. Your workflow is regional - the wood region had a mask, the glass region had a mask, each was conditioned separately. When the render is done, you want to composite it back into your 3D scene or iterate on it in the original design tool, and for that you need to know which pixels belonged to which region. Most tools just discard that. This node embeds each mask as a base64-encoded PNG inside the saved file's metadata under keys like pseudocomfy_mask_00, pseudocomfy_mask_01, and so on, ready for the plugin (or any script) to read back out. It's a closed loop: snapshot in, render + masks out.

    What goes in

    • imgs - the images to save. Straightforward.
    • filename_prefix (default pseudocomfy) - same as the built-in Save Image: a prefix for the filename, and it supports the formatting templates like %date:yyyy-MM-dd% or %Empty Latent Image.width% to pull values from other nodes into the name.
    • msks (optional) - the masks to embed. This is the point of the node. They must be shaped [1, H, W]; if they're a different size than the image, they're silently rescaled to match before embedding. Missing masks just mean the metadata has fewer pseudocomfy_mask_XX entries.

    It also embeds the standard workflow metadata (the prompt and extra_pnginfo), so you keep the normal drag-image-back-in-to-reconstruct-the-workflow behavior on top of the masks. It's an output node - no outputs, it just writes files to your output folder and reports them in the UI.

    Notes from the trenches

    • It's a list-in node. INPUT_IS_LIST = True, so imgs and msks arrive as lists of batches. If you feed it from a normal single-image wire, it still works - the node unwraps singletons - but be aware the plumbing expects lists.
    • Metadata size adds up. Every mask is a full PNG in the file's metadata. A 1600×900 render with eight masks produces a noticeably larger PNG than a plain save. If your masks are huge, that's expected, not a bug.
    • Round-trip requires tooling on the other end. The metadata format is documented in the pack's snapshot spec (pseudocomfy_mask_XX{format, encoding, size, data}), so it's readable by the Pseudorandom plugin or your own script - but a generic image viewer won't surface it.

    Install is pack-standard: clone Pseudocomfy into custom_nodes and restart, or grab it from Manager. And the Windows-portable diffusers install the README insists on applies here too.

    CategoryPseudocomfy/IO

    Inputs (3)

    NameTypeDefaultDescription
    imgsIMAGEThe images to save.
    filename_prefixSTRINGpseudocomfyThe prefix for the file to save. This may include formatting information such as %date:yyyy-MM-dd% or %Empty Latent Image.width% to include values from nodes.
    msksoptMASKThe masks to embed in the image.

    Outputs (0)

    No outputs