Nodes/ComfyUI-ArchiGraph/Save Nparray Image πŸ¦β€πŸ”₯
ComfyUI Node

Save Nparray Image πŸ¦β€πŸ”₯

Turn your OpenCV result into a real PNG in the output folder

By vincentfsΒ·Created 2 years agoΒ·Updated 9 months agoΒ· 3
Save Nparray Image πŸ¦β€πŸ”₯
  • nparrays
    β—„filename_prefixComfyUIβ–Ί

    When an ArchiGraph workflow finishes its OpenCV pass, you're left holding a numpy array - and the normal Save Image node won't touch it. This is the node that converts that array back into a standard image and saves it exactly the way core ComfyUI saves things: into your output folder, with a counter suffix, metadata embedded, subfolders and %date% formatting all supported. It's the proper exit from the OpenCV half of the graph.

    Why you'd reach for it

    If AG Preview Nparray Image is the throwaway debug view, this is the keeper. Once you've run your Sobel or threshold or contour pass and you're happy with it, you want the result as an actual image file you can look at, share, or feed to the rest of the pipeline later. This node gives you the same behavior you already know from ComfyUI's built-in Save Image - because under the hood, it is the built-in Save Image.

    How it works

    The source is revealing: the class literally subclasses ComfyUI's core SaveImage. On execution it first routes your NPARRAY through the pack's Nparray2Image converter (the same logic behind AG To Image), which handles grayscale and BGR arrays and normalizes them to a float 0–1 RGB tensor. Then it calls the parent's save_images() with your prefix, prompt, and PNG info. That means you inherit every nicety of the core node: the five-digit counter so reruns never overwrite, subfolder support in the prefix, and workflow metadata embedded in the PNG.

    The inputs

    • nparrays - the array(s) to save. Tooltip: "The nparray images to save."
    • filename_prefix - default "ComfyUI", and it behaves exactly like the core Save Image prefix. That includes formatting tokens like %date:yyyy-MM-dd% and referencing other nodes' values, e.g. %Empty Latent Image.width%, plus subfolders if you type one.

    No outputs - it's an output node whose job is purely the side effect of writing files.

    Installing it

    Same pack, same story: ComfyUI Manager β†’ search "ArchiGraph" β†’ install β†’ restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/vincentfs/ComfyUI-ArchiGraph
    cd ComfyUI-ArchiGraph
    pip install -r requirements.txt   # or install.bat / install.sh on Windows
    

    The pack brings in opencv-python, opencv-contrib-python, matplotlib, and numba. No models, no API keys.

    Where people get burned

    The array-shape trap from the preview node applies here too: this expects a valid 2D or 3D image-like array. If your array is still float 0–1, the conversion path will produce a black image - scale and cast to uint8 first (or run it through a normalizing step). The conversion only handles grayscale (H,W or H,W,1) and 3-channel arrays; a 4-channel array slips through unprocessed and will save as garbage.

    Also keep the mental model straight: this saves to the output directory and is permanent, whereas its preview sibling writes throwaway files to the temp directory. If you're still tuning parameters, use the preview; switch to this one only when you actually want the file. And since the counter only increments per prefix per session, same-prefix reruns across separate ComfyUI restarts can collide - ComfyUI resolves that with a fresh suffix, but it's worth giving distinct prefixes for distinct outputs anyway.

    CategoryπŸ¦β€πŸ”₯ ArchiGraph/πŸ› οΈ Utils

    Inputs (2)

    NameTypeDefaultDescription
    nparraysNPARRAYThe nparray images to save.
    filename_prefixSTRINGComfyUIThe 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.

    Outputs (0)

    No outputs