> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simular.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Image

# Class: Image

Defined in: [index.d.ts:484](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L484)

Represents an image.

## Constructors

### Constructor

> **new Image**(): `Image`

#### Returns

`Image`

## Accessors

### dimensions

#### Get Signature

> **get** **dimensions**(): \[`number`, `number`]

Defined in: [index.d.ts:513](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L513)

Returns the image dimensions as `[width, height]` in pixels.

##### Returns

\[`number`, `number`]

## Methods

### addGrid()

> **addGrid**(`width`, `height`): `void`

Defined in: [index.d.ts:492](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L492)

Draws a cross-hair grid on the image.

Grid squares have the specified `width` and `height`.

#### Parameters

##### width

`number`

##### height

`number`

#### Returns

`void`

***

### base64()

> **base64**(): `string`

Defined in: [index.d.ts:520](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L520)

Returns the image encoded as a base64 data URL.

The result includes the MIME prefix, for example
`data:image/png;base64,...` or `data:image/jpeg;base64,...`.

#### Returns

`string`

***

### compress()

> **compress**(`quality`): `void`

Defined in: [index.d.ts:499](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L499)

Compress the image by converting it to JPEG with the specified quality.

The quality is a value between 1 and 100.
1 is the lowest possible quality and 100 is the highest quality.

#### Parameters

##### quality

`number`

#### Returns

`void`

***

### ground()

> **ground**(`model`, `concept`): \[`number`, `number`]

Defined in: [index.d.ts:535](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L535)

Locate `concept` on this image using the given grounding model and
return absolute zero-based pixel coordinates `[x, y]`.

Equivalent to `model.ground(image, concept)`

#### Parameters

##### model

[`GroundingModel`](GroundingModel.mdx)

##### concept

`string`

#### Returns

\[`number`, `number`]

***

### save()

> **save**(`path`): `void`

Defined in: [index.d.ts:486](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L486)

Path includes the file name and the extension.

#### Parameters

##### path

`string`

#### Returns

`void`

***

### shrink()

> **shrink**(`nwidth`, `nheight`): `void`

Defined in: [index.d.ts:511](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L511)

Resizes this image if it is larger than the desired size. The image's
aspect ratio is preserved. The image is scaled to the maximum
possible size that fits within the bounds specified by nwidth and
nheight.

This method operates on pixel channel values directly without taking
into account color space data.

We commonly use this to resize the image to 1920x1080.

#### Parameters

##### nwidth

`number`

##### nheight

`number`

#### Returns

`void`

***

### fromBase64()

> `static` **fromBase64**(`base64`): `Image`

Defined in: [index.d.ts:528](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L528)

Decodes a base64 image string into an image.

Accepts either a raw base64 payload or a data URL such as
`data:image/png;base64,...`, `data:image/jpeg;base64,...`, or
`data:image/jpg;base64,...`.

#### Parameters

##### base64

`string`

#### Returns

`Image`
