> ## 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.

# Screenshot

> Represents a screenshot capture.

## Constructor

```typescript
Screenshot(): Screenshot
```

### Returns

`Screenshot`

## Properties

<ResponseField name={"dimensions"} type={"[number, number]"} required>
  Returns the screenshot dimensions as `[width, height]` in pixels.
</ResponseField>

## Methods

### base64()

```typescript
base64(): string
```

Returns the image encoded as raw base64, without a MIME prefix.

#### Returns

`string`

### base64DataUrl()

```typescript
base64DataUrl(): string
```

Returns the image encoded as a base64 data URL.

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

#### Returns

`string`

### compress()

```typescript
compress(quality: number): void
```

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

<ResponseField name={"quality"} type={"number"} required />

### drawBox()

```typescript
drawBox(bounds: BoundingBox, thickness: number, red: number, green: number, blue: number): void
```

Draws the outline of the axis-aligned rectangle `bounds` on the
screenshot. Useful for visualizing bounding boxes returned from grounding,
element / window `boundingBox()` queries, ground-truth annotations, etc.

`bounds` is in **global desktop** coordinates (the same space element /
window `boundingBox()` and grounding results use); its corners are
converted to image pixels — inverting the capture offset and any
resampling — before drawing, so an element's `boundingBox()` can be passed
straight in. It covers `[left, right) × [top, bottom)` (`right` / `bottom`
exclusive). The border is `thickness` pixels wide, drawn inset, in the
opaque RGB `(red, green, blue)` color. Pixels that map outside the image
bounds are silently clipped. Throws when `thickness` is `0` or `bounds` is
degenerate (`right <= left` or `bottom <= top`).

#### Parameters

<ResponseField name={"bounds"} type={"BoundingBox"} required />

<ResponseField name={"thickness"} type={"number"} required />

<ResponseField name={"red"} type={"number"} required />

<ResponseField name={"green"} type={"number"} required />

<ResponseField name={"blue"} type={"number"} required />

### drawDot()

```typescript
drawDot(x: number, y: number, radius: number, red: number, green: number, blue: number): void
```

Paints a filled disc on the screenshot. Useful for visualizing point
coordinates returned from grounding, element / layout queries, etc.

`x` / `y` are **global desktop** coordinates (the same space
`Screenshot.ground` returns and \[`Machine.moveMouse`] consumes), which are
converted to image pixels — inverting the capture offset and any
resampling — before drawing. So a `ground(...)` result or an element's
`boundingBox()` corner can be passed straight in. `radius` is the disc
radius in pixels (`0` paints a single pixel at the centre).
`(red, green, blue)` is the fill color; alpha is always 255 (opaque
replacement of the underlying pixel).

Coordinates that map outside the image bounds silently produce no pixel,
so the helper is safe to call even for points that fall outside the
captured region.

#### Parameters

<ResponseField name={"x"} type={"number"} required />

<ResponseField name={"y"} type={"number"} required />

<ResponseField name={"radius"} type={"number"} required />

<ResponseField name={"red"} type={"number"} required />

<ResponseField name={"green"} type={"number"} required />

<ResponseField name={"blue"} type={"number"} required />

### drawGrid()

```typescript
drawGrid(width: number, height: number): void
```

Draws a cross-hair grid on the image.

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

#### Parameters

<ResponseField name={"width"} type={"number"} required />

<ResponseField name={"height"} type={"number"} required />

### ground()

```typescript
ground(model: GroundingModel, concept: string): [number, number]
```

Locate `concept` on this screenshot using the given grounding model and
return the corresponding **global desktop coordinates** `[x, y]` in
OS-native units (may be negative on multi-monitor setups; see
\[`Machine`]). The output can be fed
directly to primitives that expect global screen coordinates.

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

#### Parameters

<ResponseField name={"model"} type={"GroundingModel"} required />

<ResponseField name={"concept"} type={"string"} required />

#### Returns

`[number, number]`

### save()

```typescript
save(path: string): void
```

Path includes the file name and the extension.

#### Parameters

<ResponseField name={"path"} type={"string"} required />

### shrink()

```typescript
shrink(nwidth: number, nheight: number): void
```

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

<ResponseField name={"nwidth"} type={"number"} required />

<ResponseField name={"nheight"} type={"number"} required />

### toMachineCoordinates()

```typescript
toMachineCoordinates(x: number, y: number, coordType: ScreenshotCoordinateType): [number, number]
```

Converts a point in this screenshot to the machine's coordinate space.

The result is in the library's canonical coordinate space (OS-native
units; see \[`Machine`]), so it can be fed straight to
\[`Machine.moveMouse`] without conversion.

Screenshots may represent only part of a display, and the captured
region may have been resampled to a different image size, so this
rescales `(x, y)` from image space back to the captured region (for
example, when moving the mouse to the same on-screen point).

See `ScreenshotCoordinateType` for how `coord_type` affects
interpretation of `(x, y)`.

#### Parameters

<ResponseField name={"x"} type={"number"} required />

<ResponseField name={"y"} type={"number"} required />

<ResponseField name={"coordType"} type={"ScreenshotCoordinateType"} required />

#### Returns

`[number, number]`
