ComfyUI Node

AP Bridge Save

Save images and masks together from one node, and let them ride through as outputs

By adampolczynski·Created 6 months ago·Updated 6 months ago· 1
AP Bridge Save
  • images
  • masks
  • images
  • masks
filename_prefixAP_Bridge/bridge
save_imagestrue
save_maskstrue
save_image_mask_togetherfalse
compress_level4

A save node is usually a dead end - it consumes a batch and outputs nothing, so if you want to keep the data flowing you have to split the wire. AP Bridge Save is the exception: it writes images and/or masks to disk and passes both through as outputs, so it slots into a pipeline as a tap rather than a wall. It's the sibling of AP Bridge Preview Batch (preview shows, save writes) and it's the natural end-point for the pack's batch video work.

The feature that sets it apart from the built-in Save Image is the mask handling. Built-in save is image-only; here you can save images, save masks, or save them combined into a single file (save_image_mask_together=true), with a compress_level knob for the PNG write. If you're producing inpaint masks, occlusion masks, or anything where the mask is as important as the pixels, this saves you a second save node and keeps the two in lockstep.

The mechanism

It takes optional images and masks, writes the enabled ones into your ComfyUI output directory under filename_prefix (default AP_Bridge/bridge, subdirectories get created as needed), and returns both inputs unchanged as outputs - which is the "bridge" in the name. There are a few deliberate guardrails: save_image_mask_together=true requires both images and masks to be connected (it raises a clear error otherwise, since a combined file with only one of them is meaningless), and the same error style shows up throughout the pack. It's an output node, so it always runs - which means if it's mid-pipeline, the save fires every execution.

The inputs that matter

  • filename_prefix - output subpath and base name.
  • save_images / save_masks - toggles for what gets written. Both default true.
  • save_image_mask_together - write a combined image+mask file instead of separate ones. Needs both inputs wired.
  • compress_level - PNG compression 0–9 (default 4). Higher = smaller files, slower writes. For large frame batches this matters more than you'd think; masks compress well.

Outputs

images and masks, passed through byte-for-byte - so you can save and keep feeding the same batch downstream, which is the thing built-in save won't let you do without a splitter.

Installing it

Pack-wide install: ComfyUI Manager (search "AP_OpticalFlow"), or

cd ComfyUI/custom_nodes
git clone https://github.com/adampolczynski/ComfyUI_AP_OpticalFlow
python -m pip install -r custom_nodes/ComfyUI_AP_OpticalFlow/requirements.txt

Restart. Dependency: torchvision>=0.15.

Where it fits

End of a frame-by-frame pipeline - the loop output, the stitched inpaint result, the composited flow frame - where you want the sequence (and its masks) on disk while still passing the batch onward for preview or further processing. It's unglamorous but genuinely handy: one node, images plus masks, passthrough included. If you just need to save a single image with no mask and no passthrough, the built-in Save Image is fewer moving parts - reach for the bridge when the batch and the masks are the point.

CategoryAP_OpticalFlow

Inputs (7)

NameTypeDefaultDescription
filename_prefixSTRINGAP_Bridge/bridge
save_imagesBOOLEANtrue
save_masksBOOLEANtrue
save_image_mask_togetherBOOLEANfalse
compress_levelINT40–9
imagesoptIMAGE
masksoptMASK

Outputs (2)

NameTypeDescription
imagesIMAGE
masksMASK