Save Image If
Save Image If — the Save node that only keeps the good ones
- image
- image
- condition
Every ComfyUI workflow ends the same way: Save Image, and an output folder slowly filling with rerolls you'd never hang on a wall. SaveImageIfNode from the phobod/ComfyUI_Face_similarity pack is the Save Image node with a bouncer at the door. Give it an image and a BOOLEAN condition, and it writes the file only when the condition is True. When it's False, it skips the save and prints "Condition is False - image not saved" to the console.
The reason this node exists is the pack's other half: Face Similarity (InsightFace) emits an is_same_person boolean, and stitching the two together gives you "save only the generations that still look like the reference." But the condition doesn't have to come from face scoring - any boolean wire works. A comparison verdict, a switch you flip manually, a counter that lets the Nth good pass through. If your workflow can produce a True/False, this node can gate a save on it.
How it works
Under the hood it's deliberately boring. If the condition is False it returns immediately without writing anything. If True, it calls the same folder_paths.get_save_image_path machinery the core Save Image node uses, so files land in ComfyUI's output directory with the usual zero-padded counter (ComfyUI_00001.png and friends) and respect your filename_prefix.
One thing worth knowing if you care about round-tripping: it saves a plain PNG via PIL and embeds no ComfyUI workflow metadata. Drag a core-Save-Image result back onto the canvas and you get the whole graph back; drag one of these in and you get the image and nothing else. If embedded metadata matters to you, do the actual saving with a standard Save Image and use this node's boolean output to gate a reroll or a branch instead - the trade for conditional saving is losing that self-documenting PNG.
Inputs and outputs
Three inputs, all required:
image- IMAGE, what you might save.condition- BOOLEAN, the bouncer. True saves, False skips.filename_prefix- STRING, defaultComfyUI.
Two outputs, both pass-throughs: image comes back out unchanged, and condition is re-emitted as the boolean that actually got applied (True if saved, False if skipped). That makes it chainable - downstream nodes keep receiving the image and the flag, which is handy when your "only keep winners" branch keeps going instead of ending at the disk.
Installing it
Same pack as Face Similarity, so same install. ComfyUI Manager, search "Face Similarity", install the pack; or:
cd ComfyUI/custom_nodes
git clone https://github.com/phobod/ComfyUI_Face_similarity.git
cd ComfyUI_Face_similarity
pip install -r requirements.txt
Fair warning if you only want this one node: it drags the whole InsightFace stack along with it (insightface, onnxruntime, opencv), which is a heavyweight price to pay for a conditional save. If you're already running Face Similarity or any face-ID workflow, it's free - that's clearly the intended audience. If you're not, a boolean primitive gating a reroll or a manual cut is honestly most of what this gives you.
Gotchas
- The image output passes through regardless of the condition. This is a save gate, not a flow gate. The rejected image still flows downstream, so if you've got a preview or another Save node connected after it, rejected images will still show up there. Don't wire it into a branch expecting it to block the data.
- No workflow metadata in the saved PNG (covered above).
- It's a small, fresh, single-author pack with no community footprint yet - the code is short enough to read in one sitting if you want to verify exactly what it does before trusting your output folder to it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| condition | BOOLEAN | — | |
| filename_prefix | STRING | ComfyUI | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| condition | BOOLEAN | — |