Math, SIMD & media6 exports
Raw Markdown/image/avif
AVIF image decoder and encoder for files and byte slabs.
Functions & symbols#
Coder#
constructor
Creates a streaming AVIF encoder writing rows directly to `writable`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
width | Int | required | Output width in pixels |
height | Int | required | Output height in pixels |
encoding | KeySymbol | String | required | Input pixel encoding (:rgb8, :rgba8, :luma8) |
writable | Stream | File | required | Destination writable stream or file handle |
options | Map | optional | Optional AVIF encoder settings (e.g. :quality) |
Returns:
Any(let coder (avif/Coder 800 600 :rgba8 out-file))decode-from-file#
function
Decodes a AVIF file from disk into an in-memory `Image`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
path | String | required | Path to input .avif file |
Returns:
Any(let img (avif/decode-from-file "photo.avif"))decode-from-slab#
function
Decodes AVIF bytes from a `Slab` into an `Image`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
data | Slab | required | Encoded AVIF byte Slab |
Returns:
Any(let img (avif/decode-from-slab bytes))encode-to-file#
function
Encodes `image` as AVIF and writes the result directly to `path`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
path | String | required | Destination file path |
image | Image | required | Image map or Image value to encode |
options | Map | optional | Optional AVIF encoder options |
Returns:
Any(avif/encode-to-file "out.avif" img)encode-to-slab#
function
Encodes `image` into an in-memory AVIF byte `Slab`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
image | Image | required | Image map or Image value to encode |
options | Map | optional | Optional AVIF encoder options |
Returns:
Any(let encoded (avif/encode-to-slab img))write#
function
Writes encoded pixel bytes through an open AVIF streaming `Coder`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
coder | Coder | required | Active streaming Coder instance |
slab | Slab | required | Packed pixel buffer Slab to encode |
Returns:
Any(avif/write coder pixels)