Skip to content

smelt.image

Tier: Host — Available in every runtime, including headless mode.

Image file detection and base64 data-URL loading.

smelt.image.data_url_from_bytes

fun(bytes: string, mime: string): string

Encode raw bytes as a base64 data: URL with the given mime type.

smelt.image.is_image_file

fun(p: string): boolean

Return true if p looks like an image file (matched by extension/sniffing).

smelt.image.read_as_data_url

fun(p: string): string?, string?

Read the image at p and encode it as a data: URL. Returns (url, nil) on success or (nil, err_string) on failure.