Commands, settings, SDK functions, anything in the docs.

Reference

@ledable/sdk/webp

Decoding and encoding WebP images.

On this page

Generated from the types of the SDK. Import from @ledable/sdk/webp; an editor shows the same declarations and comments as you type.

Functions

createWebpBlob

Convenience mirroring ledable/cloud models/webp.py create_webp_blob: a single frame becomes a static image, several frames an animation.

async function createWebpBlob(
  frames: readonly RawImage[],
  frameMs: number,
  loop: boolean,
  encoder: FrameEncoder = pureFrameEncoder,
): Promise<Uint8Array>

encodeAnimatedWebp

Encode a lossless animated WebP with uniform frame duration.

async function encodeAnimatedWebp(
  frames: readonly RawImage[],
  options: AnimationOptions,
): Promise<Uint8Array>

encodeVp8lPayload

Encode one image as a VP8L chunk payload: lossless, no transforms, no color cache, no backward references — every pixel is a literal. For LED matrix frames this is small and exactly reproducible.

function encodeVp8lPayload(image: RawImage): Uint8Array

encodeWebp

Encode a single lossless WebP image.

async function encodeWebp(
  image: RawImage,
  encoder: FrameEncoder = pureFrameEncoder,
): Promise<Uint8Array>

extractVp8lPayload

Pull the VP8L chunk payload out of a static lossless WebP file.

function extractVp8lPayload(webp: Uint8Array): Uint8Array

hasTransparency

function hasTransparency(image: RawImage): boolean

splitWebpFrames

Split a lossless WebP file into standalone single-frame files, one per ANMF chunk; a still file is returned unchanged. Frames must cover the whole canvas without blending, which is the only layout `encodeAnimatedWebp` writes; any other layout would need canvas reconstruction, so it is rejected instead of being decoded into the wrong pixels.

function splitWebpFrames(webp: Uint8Array): Uint8Array[]

Constants

pureFrameEncoder

const pureFrameEncoder: FrameEncoder = (image) =>
  Promise.resolve(riff([chunk("VP8L", encodeVp8lPayload(image))]))

Interfaces

AnimationOptions

interface AnimationOptions {
  /** Per-frame duration in milliseconds. */
  readonly frameMs: number;
  /** true = loop forever (ANIM loop count 0), false = play once (count 1). */
  readonly loop: boolean;
  readonly encoder?: FrameEncoder;
}

RawImage

Structurally compatible with

interface RawImage {
  readonly width: number;
  readonly height: number;
  /** Non-premultiplied RGBA, row-major. */
  readonly data: Uint8ClampedArray | Uint8Array;
}

Types

FrameEncoder

Encodes one frame as a complete static lossless WebP file (RIFF + VP8L). The default is the built-in pure-TS encoder;

type FrameEncoder = (image: RawImage) => Promise<Uint8Array>;