/** Default target width (px) used when resizing image frames. */ export declare const DEFAULT_IMAGE_WIDTH = 1024; /** Default target height (px) used when resizing image frames. */ export declare const DEFAULT_IMAGE_HEIGHT = 1024; /** Default JPEG quality (0-100) used when encoding image frames. */ export declare const DEFAULT_IMAGE_QUALITY = 75; /** Output image format. */ export type ImageFormat = 'JPEG' | 'PNG'; /** Target dimensions (in pixels) for resizing an image. */ export type ResizeOptions = { readonly width: number; readonly height: number; }; /** Create a {@link ResizeOptions} from width and height in pixels. */ export declare function ResizeOptions(width: number, height: number): ResizeOptions; /** Options for {@link EncodeOptions}. */ export type EncodeOptionsInit = { /** Output format. Default: `'JPEG'`. */ format?: ImageFormat; /** Target dimensions, or `null` to keep the source size. Default: 1024x1024. */ resizeOptions?: ResizeOptions | null; /** JPEG quality, 0-100 (ignored for PNG). Default: `75`. */ quality?: number; }; /** * Controls how an image frame is encoded. * * Note: by default the image is resized to 1024x1024. To preserve the source * dimensions, construct with `{ resizeOptions: null }`. */ export type EncodeOptions = { readonly format: ImageFormat; readonly resizeOptions: ResizeOptions | null; readonly quality: number; }; /** * Create an {@link EncodeOptions}. Pass `{ resizeOptions: null }` to preserve the * source dimensions; omitting it resizes to 1024x1024. */ export declare function EncodeOptions(init?: EncodeOptionsInit): EncodeOptions; /** Encode options applied by {@link coerceImageToJpegBytes} when a frame must be re-encoded. */ export declare const DEFAULT_REALTIME_ENCODE_OPTIONS: EncodeOptions; /** * An image frame accepted by the encoding helpers: raw encoded bytes * (`Buffer`/`Uint8Array`/`ArrayBuffer`) or an object exposing `toImage()` that * returns encoded bytes. */ export type ImageFrame = Buffer | Uint8Array | ArrayBuffer | { toImage: () => Buffer | Uint8Array | Promise; }; /** * Encode an image frame to JPEG or PNG bytes, optionally resizing. Requires the * optional `sharp` dependency. Uses {@link EncodeOptions} defaults when `options` * is omitted or `null`. */ export declare function encode(frame: ImageFrame, options?: EncodeOptions | null): Promise; export type CoerceImageOptions = { /** Encode options used only when the frame must be re-encoded. Defaults to {@link DEFAULT_REALTIME_ENCODE_OPTIONS}. */ options?: EncodeOptions | null; }; /** * Return JPEG-ready bytes for an image frame, re-encoding only when necessary. * * If `frame` is already encoded bytes (`Buffer`/`Uint8Array`/`ArrayBuffer`), it is * returned as-is (assumed to be a valid JPEG/PNG) and `sharp` is not required. Otherwise * the frame is encoded with `options` (or {@link DEFAULT_REALTIME_ENCODE_OPTIONS}). */ export declare function coerceImageToJpegBytes(frame: ImageFrame, opts?: CoerceImageOptions): Promise; /** * Detect an image's MIME type from its leading magic bytes. Recognizes JPEG, PNG, * GIF, BMP, and WEBP. Returns `null` if the input is not bytes-like or unrecognized. */ export declare function detectImageMime(bytes: Buffer | Uint8Array): string | null; /** Encode image bytes as a `data:` URL with the given MIME type. */ export declare function bytesToDataUrl(bytes: Buffer | Uint8Array | ArrayBuffer, mimeType: string): string;