---
title: "ImageData"
---
> **ImageData**: `object`

Defined in: [api/node/typescript/index.ts:169](https://github.com/slint-ui/slint/blob/master/api/node/typescript/index.ts#L169)

Use these functions to load an [ImageData](/latest/docs/node/api/variables/imagedata/) from an image file.
The supported formats are SVG, PNG, and JPEG.

## Type Declaration

### loadFromData()

> **loadFromData**(`data`, `format?`): [`ImageData`](/latest/docs/node/api/interfaces/imagedata/)

Decodes the image from `data`, the content of an image file.

`format` is the lowercase file extension of the data, such as `"png"` or `"svg"`.
Without it, the format is guessed from the data.
Only SVG data that starts with `<?xml` or `<svg` is recognized.

#### Parameters

##### data

`Uint8Array`

##### format?

`string`

#### Returns

[`ImageData`](/latest/docs/node/api/interfaces/imagedata/)

#### Throws

if the data can't be decoded.

### loadFromPath()

> **loadFromPath**(`path`): [`ImageData`](/latest/docs/node/api/interfaces/imagedata/)

Loads the image from the file at `path`.

#### Parameters

##### path

`string`

#### Returns

[`ImageData`](/latest/docs/node/api/interfaces/imagedata/)

#### Throws

if the file can't be read or decoded.