ComfyUI Node

Save AVIF

Save the web-sized image, not the 10MB PNG

By pkpkTech·Created 3 years ago·Updated 2 years ago· 3
Save AVIF
  • images
  • image( pass-through )
filename_prefixComfyUI
c_quality75
enc_speed6
subsampling4:2:0

AVIF is the answer to "why is my 1024×1024 PNG 8 MB?" It's an AV1-based image format that gets you near-lossless quality at a fraction of the PNG's size - think 10–20× smaller on flat art, usually 2–4× smaller than JPEG at the same quality. If your output is heading to a website, a Discord upload, or a model card preview, this is the node that turns ComfyUI's default Save Image into a file you'd actually post.

The catch, and it's a real one: AVIF encodes slowly, and it isn't universally readable yet. This node is a drop-in replacement for Save Image that writes .avif instead of .png, and it's honest about the tradeoffs - the quality and speed knobs are right there on the node instead of hidden in a submenu.

How it works

Under the hood it's just Pillow plus the pillow-avif-plugin, which is the entire dependency list - there's nothing heavy here, no model downloads, no API. The node converts your image tensor to a numpy array, hands it to Pillow's AVIF encoder with your quality, speed, and subsampling settings, and writes it into ComfyUI/output/ with the same auto-incrementing filename scheme you already know from Save Image.

Two details are worth knowing. First, it embeds your prompt and full workflow JSON into the file's EXIF metadata - the same trick ComfyUI uses for PNGs, so you can drag a saved .avif back onto the canvas and get the whole graph back. That required shipping a small JS extension that hooks ComfyUI's file-drop handler, and the install copies it into your extensions folder automatically. Second, the node respects ComfyUI's --disable-metadata flag, so you're not leaking your prompt when you'd rather not.

The inputs that matter

You'll touch four things, and only two of them require a thought:

  • c_quality (0–100, default 75) - the encoder quality. The author's note is the truth: 100 is lossless. But lossless AVIF is slow and barely smaller than a PNG, so 75–90 is the sweet spot for real-world files. Don't chase 100.
  • enc_speed (0–10, default 6) - slowest/smallest at 0, fastest/largest at 10. This is the knob that makes encoding take "a little time" or a lot. Leave it at 6 unless you're batch-saving a hundred images.
  • filename_prefix - the usual prefix; you can use %date%-style replacements.
  • subsampling (optional, default 4:2:0) - chroma resolution. 4:4:4 keeps full color detail and is the one to pick if you're archiving, at the cost of bigger, slower encodes. 4:2:0 is fine for photos, slightly lossy for flat UI art.

The output is a pass-through IMAGE of whatever you fed in - the node doesn't transform anything. The intended use: wire it into a node that plays a sound, so you get an audible "encoding's done" instead of staring at a frozen canvas while the AVIF encoder grinds.

Install

ComfyUI Manager is the easy path - search for ComfyUI-SaveAVIF and install, which pulls in the pillow-avif-plugin requirement. Or do it by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/pkpkTech/ComfyUI-SaveAVIF
cd ComfyUI-SaveAVIF
pip install -r requirements.txt

Then restart ComfyUI. There's no heavy dependency to babysit - the whole pack is one node and one Python plugin.

Where people get burned

The format itself is the trap, not the install. AVIF support in viewers is spotty: Windows Photos and Paint won't open it out of the box (you need the AV1 Video Extension and HEIF Image Extensions from the Store), and A1111's PNG Info can't read it - that whole "workflow included" culture lives in PNGs, so if you're sharing AVIF files with other generators, the metadata they carry may not travel. Browsers are fine with AVIF; your OS's image viewer might not be. So: use this for web-sized deliverables, not as your default Save Image replacement for files you'll keep re-opening on Windows.

Also don't be surprised when a big batch takes a while - AVIF encoding is genuinely slower than PNG or JPEG. That's the price of the smaller file, and the pass-through output exists precisely so you can find out when it's done. If you need the workflow round-trip to survive, keep a PNG copy in the graph alongside it.

Categoryimage

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
filename_prefixSTRINGComfyUI
c_qualityINT750–100
enc_speedINT60–10
subsamplingoptCOMBO4:2:03 options: 4:2:0, 4:2:2, 4:4:4

Outputs (1)

NameTypeDescription
image( pass-through )IMAGE