---
title: addImage
slug: viewer-2d/methods/addImage
docTags: 
createdAt: 2024-02-21T14:33:53.989Z
---

Adds an image to the specified location.

## Example

::codepen{url="https://codepen.io/Catenda/embed/qBzPvaK"}

## Usage

```javascript
const image = {
  height: 10,
  url: "https://placehold.co/400",
  width: 10,
  x: 0,
  y: 0
};

const imageId = viewer2d.addImage(image);
```

## Parameters

### image

Image to add.

| **Type** | **Required** |
| -------- | ------------ |
| Object   | Yes          |

**Properties**

| **Name**  | **Type** | **Required** | **Description**                     |
| --------- | -------- | ------------ | ----------------------------------- |
| `height`  | Number   | Yes          | Height of the image in pixels       |
| `id`      | String   | No           | User provided id for the image      |
| `onError` | Function | No           | Function called when error event    |
| `onLoad`  | Function | No           | Function called when load event     |
| `rotate`  | Boolean  | No           | Image rotates with the model        |
| `width`   | Number   | Yes          | Width of the image in pixels        |
| `url`     | String   | Yes          | Url of the image                    |
| `x`       | Number   | Yes          | X coordinate of the image in pixels |
| `y`       | Number   | Yes          | Y coordinate of the image in pixels |
| `zIndex`  | Number   | No           | The order of overlapping images     |

## Return Value

Id of the image.

| **Type** |
| -------- |
| String   |

