Math, SIMD & media6 exports
Raw Markdown/image/jpeg
JPEG image decoder and encoder with configurable quality for files and byte slabs.
Functions & symbols#
Coder#
constructor
Creates a streaming JPEG 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 JPEG encoder settings (e.g. :quality) |
Returns:
Any(let coder (jpeg/Coder 800 600 :rgba8 out-file))decode-from-file#
function
Decodes a JPEG file from disk into an in-memory `Image`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
path | String | required | Path to input .jpeg file |
Returns:
Any(let img (jpeg/decode-from-file "photo.jpeg"))decode-from-slab#
function
Decodes JPEG bytes from a `Slab` into an `Image`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
data | Slab | required | Encoded JPEG byte Slab |
Returns:
Any(let img (jpeg/decode-from-slab bytes))encode-to-file#
function
Encodes `image` as JPEG 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 JPEG encoder options |
Returns:
Any(jpeg/encode-to-file "out.jpeg" img)encode-to-slab#
function
Encodes `image` into an in-memory JPEG byte `Slab`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
image | Image | required | Image map or Image value to encode |
options | Map | optional | Optional JPEG encoder options |
Returns:
Any(let encoded (jpeg/encode-to-slab img))write#
function
Writes encoded pixel bytes through an open JPEG streaming `Coder`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
coder | Coder | required | Active streaming Coder instance |
slab | Slab | required | Packed pixel buffer Slab to encode |
Returns:
Any(jpeg/write coder pixels)