Skip to content
1 min read · 102 words

Function: toBytes()

ts
function toBytes(input: GenerationImageInput): Promise<{
  bytes: Uint8Array;
  mimeType?: string;
}>;

Defined in: src/batteries/generation/_shared/index.ts:69

Normalizes any GenerationImageInput form to plain bytes plus an optional MIME type.

Parameters

ParameterTypeDescription
inputGenerationImageInputThe image input in any accepted form.

Returns

Promise<{ bytes: Uint8Array; mimeType?: string; }>

The normalized bytes and MIME type (MIME undefined only for the bare-Uint8Array form).

Remarks

A bare Uint8Array passes through with mimeType: undefined (the caller declared no MIME). A GenerationBytesInput passes its bytes/mimeType through unchanged. A GenerationMediaLike is resolved by awaiting asBytes() and reading mimeType off it.