Math, SIMD & media4 exports
Raw Markdown/image
In-memory raster Image decoding/encoding with format detection, cropping, and high-quality resizing.
Functions & symbols#
Image#
constructor
Constructs an `Image` value from pixel dimensions, channel encoding, and a raw `Slab`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
width | Int | required | Image width in pixels |
height | Int | required | Image height in pixels |
encoding | KeySymbol | String | required | Pixel layout encoding (e.g. :rgb8, :rgba8, :luma8) |
data | Slab | required | Raw packed pixel buffer Slab |
options | Map | optional | Optional metadata map |
Returns:
Any(let img (image/Image 256 256 :rgba8 raw-slab))crop#
function
Returns a cropped sub-region of `image` at `(x, y)` with size `width x height`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
image | Image | required | Source image map or Image value |
x | Int | required | Left crop offset in pixels |
y | Int | required | Top crop offset in pixels |
width | Int | required | Cropped width in pixels |
height | Int | required | Cropped height in pixels |
Returns:
Any(let thumb (image/crop img 0 0 128 128))detect-format#
function
Detects the image container format (:png, :jpeg, :webp, :avif, :gif, ...) from encoded file header bytes.
| Parameter | Type | Optional | Description |
|---|---|---|---|
data | Slab | required | Encoded image header bytes |
Returns:
Any(image/detect-format raw-bytes) ; -> :pngresize#
function
Resizes `image` to `width x height` using the configured resampling filter (defaults to Lanczos3).
| Parameter | Type | Optional | Description |
|---|---|---|---|
image | Image | required | Source image |
width | Int | required | Target width in pixels |
height | Int | required | Target height in pixels |
options | Map | optional | Optional {:filter :lanczos3 | :triangle | :nearest} |
Returns:
Any(let resized (image/resize img 800 600))