ComfyUI Node

Save Mask

Dump a MASK straight to a PNG

By ruiqutech·Created 2 years ago·Updated 2 years ago· 0
Save Mask
  • masks
    filename_prefixComfyUI_Mask

    You can't eyeball a MASK. It's a single-channel tensor of numbers between 0 and 1 sitting inside the graph - ComfyUI doesn't render it for you the way it renders an IMAGE, so unless you actively save it somewhere, you're trusting that whatever produced it (a SAM detector, a CLIPSeg pass, a hand-painted selection, a chain of grow/erode nodes) did what you think it did. SaveMask exists to close that gap: it writes the mask out as an actual image file so you can look at it.

    What it does

    The node takes a mask (or a batch of masks - the input is plural, masks) and writes each one to your ComfyUI output directory as a grayscale image, under filename_prefix (default ComfyUI_Mask). White is the masked/selected region, black is everything else - the same convention ComfyUI uses everywhere else a mask shows up, so what you see in the saved file is exactly what a downstream node would treat as "selected."

    Functionally it's the same move as this pack's VAEDecodeSave: instead of chaining a "convert this to something saveable" node into a Save Image node, it's one node that does both. No separate Mask to Image conversion required.

    Why you'd actually use it

    Two real reasons. The first is debugging: before you trust an automated mask into an inpaint or a composite, save it once and look at it. It costs nothing and catches an embarrassing amount of "why did my inpaint touch the whole image" or "why did nothing change" - usually the answer is sitting right there in a mask that's solid white or solid black when it shouldn't be. The second is reuse: if you've built a mask worth keeping (a clean segmentation, a hand-refined selection), saving it as a PNG lets you load it back into another workflow, or hand it to a tool outside ComfyUI entirely, without regenerating it.

    Inputs and outputs

    • masks (MASK, required) - what gets saved.
    • filename_prefix (STRING, default ComfyUI_Mask) - the base name for the written files.

    No outputs - this is a terminal node (is_output_node: true), same shape as VAEDecodeSave. It ends the branch of the graph it sits on.

    Installing it

    ComfyUI Manager: search RuiquNodes, install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ruiqutech/ComfyUI-RuiquNodes
    

    then restart ComfyUI. Pure utility node, no models or extra dependencies to fetch.

    Common issues

    The saved file is solid black or solid white. That's not a bug in this node - that's your actual mask. Solid black means nothing is selected (an empty mask, which will make anything downstream that expects a masked region do nothing). Solid white means everything is selected. Both are useful to catch here, at the mask stage, rather than three nodes later when your inpaint quietly regenerated the whole frame.

    You expected color and got grayscale. Masks are single-channel by definition - there's no color information to preserve. If you need to see a mask overlaid on the original image rather than in isolation, you want a compositing step, not this node; SaveMask shows you the mask itself, nothing else.

    Categoryruiqu/mask

    Inputs (2)

    NameTypeDefaultDescription
    masksMASK
    filename_prefixSTRINGComfyUI_Mask

    Outputs (0)

    No outputs