Skip to content

imageFromBuffer

imageFromBuffer(buffer, mediaType?): ImageContentPart

Defined in: core/input-content.ts:327

Create an image content part from a Buffer or Uint8Array. Automatically detects the MIME type if not provided.

Image data

Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>

ImageMimeType

Optional MIME type (auto-detected if not provided)

ImageContentPart

const imageData = await fs.readFile("photo.jpg");
const part = imageFromBuffer(imageData); // Auto-detects JPEG