AVIF
AVIF (AV1 Image File Format)
A next-generation image format based on the AV1 video codec that delivers exceptional compression efficiency, often producing files 50% smaller than JPEG at the same visual quality, with support for HDR and wide color gamut.
技術的詳細
AVIF uses the HEIF container (ISO 23008-12) with AV1 intra-frame coding (single-frame video compression). It supports 8/10/12-bit color depth, 4:2:0/4:2:2/4:4:4 chroma subsampling, HDR (PQ and HLG transfer functions), wide gamut (BT.2020), alpha channels, and animation. Encoding is computationally expensive (10-100x slower than JPEG encoding) but decoding is fast. Browser support includes Chrome 85+, Firefox 93+, and Safari 16.1+. AVIF excels particularly with photographic content, while WebP may still be preferred for its faster encoding when batch-processing large image sets.
例
```javascript
// Image compression via Canvas
canvas.toBlob(
blob => console.log(`Size: ${(blob.size/1024).toFixed(0)} KB`),
'image/jpeg',
0.8 // quality: 0.0 (smallest) to 1.0 (best)
);
// WebP output (25-34% smaller than JPEG)
canvas.toBlob(cb, 'image/webp', 0.8);
```