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

An image data type that can be displayed by the Image element.

This interface is inspired by the web [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData) interface.

Use [ImageData.loadFromPath](/latest/docs/node/api/variables/imagedata/#loadfrompath) or [ImageData.loadFromData](/latest/docs/node/api/variables/imagedata/#loadfromdata) to load an image file,
or pass an object with the `width`, `height`, and RGBA `data` of the pixels.
Pass `undefined` for an empty image.

```js
app.icon = slint.ImageData.loadFromPath("icons/app.svg");
app.preview = { width: 1, height: 1, data: new Uint8Array([255, 0, 0, 255]) };
```

## Properties

### path?

> `readonly` `optional` **path?**: `string`

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

Returns the path of the image, if it was loaded from disk. Otherwise
the property is undefined.

## Accessors

### data

#### Get Signature

> **get** **data**(): `Uint8Array`

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

Returns the image as buffer.

##### Returns

`Uint8Array`

***

### height

#### Get Signature

> **get** **height**(): `number`

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

Returns the height of the image in pixels.

##### Returns

`number`

***

### width

#### Get Signature

> **get** **width**(): `number`

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

Returns the width of the image in pixels.

##### Returns

`number`