# compressImage

```ts
function compressImage(file, opts?): Promise<CompressResult>;
```

Defined in: packages/sdk/src/web/index.ts:331

Compress a single image. Browser-only; in Node/Bun this is a no-op that
returns the input unchanged (with a warning).

Dynamically imports `@nitida/asset-compressor-web` so apps that never
call `compress: true` don't pay the compressorjs + heic2any bundle cost.

## Parameters

| Parameter | Type |
| ------ | ------ |
| `file` | `File` \| `Blob` |
| `opts` | [`CompressOptions`](/api/nitida/sdk/web/type-aliases/compressoptions/) |

## Returns

`Promise`\<[`CompressResult`](/api/nitida/sdk/web/type-aliases/compressresult/)\>