Skip to main content
A PNG or JPEG image asset, created by image or Image.fromBase64.

Constructors

Constructor

Parameters

data
ArrayBuffer | ArrayBufferView<ArrayBufferLike> | Blob

Returns

Image

Throws

data is empty or isn’t file bytes or a Blob.

Properties

data

The image file bytes, or a Blob read when the request is sent.

type

Methods

toJSON()

The reference, written by JSON.stringify wherever the image appears in a request.

Returns

string

toString()

The unique reference this image is sent under, for referencing it inside text.

Returns

string

fromBase64()

Create an image from base64-encoded file bytes, decoding them now.

Parameters

text
string The image file bytes, base64-encoded, without a data: URL prefix.

Returns

Image

Throws

text isn’t valid base64 or decodes to no bytes.

Example