zenavif-serialize

AVIF container serializer (muxer) in pure Rust. Creates MPEG/HEIF/MIAF/ISO-BMFF boxes for still images, animations, and grid layouts. Only dependency is arrayvec.
Together with zenrav1e, it enables pure-Rust AVIF encoding.
Fork of avif-serialize
Forked from avif-serialize v0.8.8 by Kornel Lesinski. Rebased on upstream as of 2026-02-14.
Changes from upstream (+2,188 lines, -55 lines):
- Animation —
AnimatedImagebuilder with per-frame durations, keyframe control, alpha track (animated.rs, 795 lines) - Grid/tiled images —
GridImagebuilder for tile-based encoding up to 256x256 (grid.rs, 695 lines) - Transforms — rotation (irot), mirror (imir), clean aperture crop (clap), pixel aspect ratio (pasp)
- Metadata — ICC profile, EXIF, and XMP embedding as separate items with item references
- Builder API —
Aviffybuilder with#[non_exhaustive]types for forward compatibility
Original still-image serialization code is largely unchanged.
Features
- Still images with optional alpha channel (separate monochrome AV1 plane)
- Animated AVIF with per-frame durations and keyframe control
- Grid/tiled images (up to 256x256 tiles) for large images
- HDR metadata — content light level (clli) and mastering display color volume (mdcv)
- Transforms — rotation, mirror, clean aperture crop, pixel aspect ratio
- Color spaces — full CICP support (BT.709, BT.2020, Display P3, PQ, HLG, etc.)
- ICC profiles, EXIF, and XMP metadata embedding
- 8/10/12-bit depth
no_stdcompatible (withalloc)
Usage
Add to Cargo.toml:
[]
= "0.1"
Still image (minimal)
Compress your pixels with an AV1 encoder first, then wrap the bitstream:
let avif_bytes = serialize_to_vec;
Still image (configured)
use ;
let avif_bytes = new
.set_color_primaries
.set_transfer_characteristics
.set_content_light_level
.set_rotation // 90 degrees CCW
.to_vec;
Animation
use ;
let mut anim = new;
anim.set_timescale; // milliseconds
anim.set_color_config;
let frames = vec!;
let avif_bytes = anim.serialize;
Grid (tiled)
use GridImage;
let mut grid = new;
grid.set_color_config;
let avif_bytes = grid.serialize?;
Compatibility
Output is tested against three independent AVIF parsers: avif-parse, zenavif-parse, and mp4parse (Mozilla). Browser compatibility has not been independently verified.
Image tech I maintain
| State of the art codecs* | zenjpeg · zenpng · zenwebp · zengif · zenavif (rav1d-safe · zenrav1e · zenavif-parse · zenavif-serialize) · zenjxl (jxl-encoder · zenjxl-decoder) · zentiff · zenbitmaps · heic · zenraw · zenpdf · ultrahdr · mozjpeg-rs · webpx |
| Compression | zenflate · zenzop |
| Processing | zenresize · zenfilters · zenquant · zenblend |
| Metrics | zensim · fast-ssim2 · butteraugli · resamplescope-rs · codec-eval · codec-corpus |
| Pixel types & color | zenpixels · zenpixels-convert · linear-srgb · garb |
| Pipeline | zenpipe · zencodec · zencodecs · zenlayout · zennode |
| ImageResizer | ImageResizer (C#) — 24M+ NuGet downloads across all packages |
| Imageflow | Image optimization engine (Rust) — .NET · node · go — 9M+ NuGet downloads across all packages |
| Imageflow Server | The fast, safe image server (Rust+C#) — 552K+ NuGet downloads, deployed by Fortune 500s and major brands |
* as of 2026
General Rust awesomeness
archmage · magetypes · enough · whereat · zenbench · cargo-copter
And other projects · GitHub @imazen · GitHub @lilith · lib.rs/~lilith · NuGet (over 30 million downloads / 87 packages)
License
BSD-3-Clause. Original code copyright Cloudflare, Inc. Fork additions copyright Imazen LLC.
Upstream Contribution
This is a fork of kornelski/avif-serialize (BSD-3-Clause). We are willing to release our improvements under the original BSD-3-Clause license if upstream takes over maintenance of those improvements. We'd rather contribute back than maintain a parallel codebase. Open an issue or reach out.