Manuscript Documentation
v2026.12.0

@std/image/codec.ms#

Import each required symbol with import Name from "@std/image/codec.ms".

Raster Type#

A decoded or to-be-encoded raster: channels is 1 (gray), 2 (gray, alpha), 3 (RGB) or 4 (RGBA) and pixels holds width * height * channels bytes, row-major.

Manuscript
type Raster {
    width Int
    height Int
    channels Int
    pixels List[UInt8]
}

Raster.channels#

Bytes per pixel, 1 to 4; even counts carry alpha.

Manuscript
channels Int

Raster.height#

Rows, at least 1.

Manuscript
height Int

Raster.pixels#

Row-major interleaved bytes.

Manuscript
pixels List[UInt8]

Raster.width#

Columns, at least 1.

Manuscript
width Int

bad Function#

Builds an EBADMSG error for malformed image data.

Manuscript
fn bad(message String) Error { ... }

byte Function#

Clamps value to 0 through 255 as a byte.

Manuscript
fn byte(value Int) UInt8 { ... }

max_of Function#

Returns the larger of a and b.

Manuscript
fn max_of(a Int, b Int) Int { ... }

min_of Function#

Returns the smaller of a and b.

Manuscript
fn min_of(a Int, b Int) Int { ... }

pixel_count Function#

Checks dimensions against max_pixels and the 2^30 hard ceiling; returns the pixel count or EBADMSG or EOVERFLOW.

Manuscript
fn pixel_count(width Int, height Int, max_pixels Int? = null) Result[Int, Error] { ... }

too_big Function#

Builds an EOVERFLOW error for dimensions past a limit.

Manuscript
fn too_big(message String) Error { ... }

unsupported Function#

Builds an ENOTSUP error for a valid but unsupported image feature.

Manuscript
fn unsupported(message String) Error { ... }

zeroed Function#

Returns count zero bytes.

Manuscript
fn zeroed(count Int) List[UInt8] { ... }