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

# Process Without UI

> Crop, resize and convert a photo in code with processImage, by the same rules as Save.

Crop, resize and convert a photo with no editor on screen.

## Make a Thumbnail

```ts thumbnail.ts theme={"dark"}
import { processImage } from '@embededitor/full/react';

const thumbnail = async (file: File): Promise<File> => {
	const { dest } = await processImage(file, {
		aspectRatio: 1,
		maxWidth: 512,
		outputQuality: 80,
		outputType: 'image/webp'
	});

	return dest;
};
```

`processImage` is exported from both entries, `/react` and `/standalone`. It resolves to `{ dest, state }`: the `File` it made, and an edit state ready for the editor's `state` prop.

## Options

`src` takes everything the editor's [`src`](https://docs.embededitor.com/guides/inline#what-src-takes) takes. Every option is optional.

| Option | Type | What it does |
| - | - | - |
| `crop` | `Rect` | The region to keep, in the file's own px. Held inside the image: moved in, and shrunk at its ratio when larger. |
| `aspectRatio` | `number \| null` | With no `crop`, keeps the largest centered window of this ratio. |
| `targetSize` | `Size` | The size to draw the result at. |
| `maxWidth` | `number` | The output's largest width, in px. |
| `maxHeight` | `number` | The output's largest height, in px. |
| `outputType` | `'image/jpeg' \| 'image/png' \| 'image/webp'` | The file type written. |
| `outputQuality` | `number` | JPEG and WebP quality, 0 to 100. |
| `watermark` | `EmbedEditorWatermark \| null` | The host's watermark, at its own values. |
| `signature` | `EmbedEditorSignature \| null` | The host's signature, at its own values. |

Without `crop` or `aspectRatio`, it keeps the whole image. Output never goes past 16.7 MP, whatever `targetSize` asks for.

Given both `crop` and `aspectRatio`, the returned state keeps `aspectRatio` only when `crop` already has that ratio. Otherwise the state is free, so reopening it never refits the crop.

## Units over 16.7 MP

A photo over 16.7 MP is worked at a smaller copy (see [Large photos](https://docs.embededitor.com/features/large-photos.md)). Mind the units:

* `crop` is in the **file's own px**, and lands on the same region of the copy.
* The returned `state` is in the **copy's px**, ready for the editor's `state` prop.

> [!WARNING]
>
> Don't pass the returned state's `crop` back as the `crop` option. Those px aren't the file's.

## Errors

`processImage` rejects with an [`EmbedEditorError`](https://docs.embededitor.com/api-reference/errors).

| `code` | When |
| - | - |
| `INVALID_PROPS` | `src` or an option is invalid. Rejects before anything loads. |
| `MARK_FAILED` | A fixed or required watermark or signature can't load. A free one is left out instead. |
| `LOAD_FAILED`, `UNSUPPORTED_FORMAT` | The image can't be fetched or read. |
| `EXPORT_FAILED` | The file can't be made, the GPU's limits included. |

> [card] [processImage](https://docs.embededitor.com/api-reference/process-image.md)
>
> The full signature.

> [card] [Watermark & Signature](https://docs.embededitor.com/features/watermark.md)
>
> Draw the host's marks on the result.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.