[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/java-packs](https://jsprismarine.dev/api/@jsprismarine/java-packs/index.md) / image

# image

## Interfaces

### RgbaImage

Defined in: [image.ts:8](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/java-packs/src/image.ts#L8)

An image as eight-bit RGBA rows, top row first.

#### Properties

##### height

> `readonly` **height**: `number`

Defined in: [image.ts:10](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/java-packs/src/image.ts#L10)

##### pixels

> `readonly` **pixels**: `Uint8Array`

Defined in: [image.ts:12](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/java-packs/src/image.ts#L12)

`width * height * 4` bytes: red, green, blue and alpha for each pixel.

##### width

> `readonly` **width**: `number`

Defined in: [image.ts:9](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/java-packs/src/image.ts#L9)

## Type Aliases

### TgaProblem

> **TgaProblem** = `object`

Defined in: [image.ts:16](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/java-packs/src/image.ts#L16)

Why a TGA did not decode, for the conversion report.

#### Properties

##### ok

> `readonly` **ok**: `false`

Defined in: [image.ts:16](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/java-packs/src/image.ts#L16)

##### reason

> `readonly` **reason**: `string`

Defined in: [image.ts:16](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/java-packs/src/image.ts#L16)

## Functions

### decodePng()

> **decodePng**(`bytes`): [`TgaProblem`](#tgaproblem) \| `object` & [`RgbaImage`](#rgbaimage)

Defined in: [image.ts:252](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/java-packs/src/image.ts#L252)

Reads a PNG file of any color type and bit depth, plain or Adam7 interlaced, with its palette
and `tRNS` transparency. A 16-bit channel keeps its high byte.

#### Parameters

##### bytes

`Uint8Array`

#### Returns

[`TgaProblem`](#tgaproblem) \| `object` & [`RgbaImage`](#rgbaimage)

The image, or why it did not read.

***

### decodeTga()

> **decodeTga**(`bytes`): [`TgaProblem`](#tgaproblem) \| `object` & [`RgbaImage`](#rgbaimage)

Defined in: [image.ts:31](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/java-packs/src/image.ts#L31)

Reads a TGA file: color-mapped, true color or grayscale, plain or run-length encoded, at 8, 16,
24 or 32 bits a pixel, with its origin at either the bottom or the top left. Those cover every
TGA in Mojang's vanilla resource pack.

#### Parameters

##### bytes

`Uint8Array`

#### Returns

[`TgaProblem`](#tgaproblem) \| `object` & [`RgbaImage`](#rgbaimage)

The image, or why it did not read.

***

### encodePng()

> **encodePng**(`__namedParameters`): `Uint8Array`

Defined in: [image.ts:153](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/java-packs/src/image.ts#L153)

Writes an image as an eight-bit RGBA PNG, every row unfiltered. The same image always gives the
same bytes with the same zlib build, which keeps a converted pack's hash stable.

#### Parameters

##### \_\_namedParameters

[`RgbaImage`](#rgbaimage)

#### Returns

`Uint8Array`

***

### isPng()

> **isPng**(`bytes`): `boolean`

Defined in: [image.ts:178](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/java-packs/src/image.ts#L178)

Whether bytes start with the PNG signature.

#### Parameters

##### bytes

`Uint8Array`

#### Returns

`boolean`
