# image-convert

> Between PNG, JPEG, WebP, AVIF and more, with control over quality and whether transparency is kept.

Source: https://tools.vukem.dev/docs/mcp/tools/image-convert/

## Behaviour

What the tool needs and what it does. The server converts nothing itself: it calls the API for you.

| Property | Value |
| --- | --- |
| Ability | `image:convert` |
| Runs | `POST /api/v1/tools/image-convert`, then downloads the result |
| CLI | `vukem-tools image convert` |
| Reads | The files named in the arguments, on the machine the server runs on |
| Writes | `output` |

## Input

| Argument | Type | Required | Notes |
| --- | --- | --- | --- |
| `input` | string | yes | Path of the file to read. |
| `output` | string | yes | Where to write the result: a file path, or a directory for a tool that yields several files. The result is downloaded at once because it expires in minutes. |
| `options` | object | no | How to convert. Only the output format is required. |
| `idempotency_key` | string | no | Up to 128 characters. Repeat a call safely: the same key returns the same conversion. |

An argument that is not in the tool's schema is refused with `invalid_input`.

### Options

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `options.crop_height` | integer | no | Crop height. 0 means no crop. min 0; max 20000 |
| `options.crop_left` | integer | no | Crop origin from the left, in source pixels. min 0; max 20000 |
| `options.crop_top` | integer | no | Crop origin from the top, in source pixels. min 0; max 20000 |
| `options.crop_width` | integer | no | Crop width. 0 means no crop. min 0; max 20000 |
| `options.effort` | integer | no | 0 to 10, meaning depends on the format. 0 uses the default. min 0; max 10 |
| `options.flip` | string | no | Horizontal or vertical. Empty means no flip. max length 16 |
| `options.height` | integer | no | Target height in pixels. 0 leaves that axis open. min 0; max 20000 |
| `options.keep_animation` | boolean | no | Keep every frame of an animated GIF or WebP. Off by default; only applies when the output format is animated too |
| `options.keep_metadata` | boolean | no | Keep EXIF, XMP and IPTC. Off by default: a photograph's EXIF often carries GPS coordinates and a device serial number |
| `options.lossless` | boolean | no | Lossless encoding for WebP, AVIF and JPEG XL. Ignored by formats with no lossless mode |
| `options.quality` | integer | no | 1 to 100 for JPEG, WebP, AVIF and JPEG XL. 0 uses the format's default. min 0; max 100 |
| `options.resize` | string | no | Fit, fill or exact. Empty leaves the size alone. max length 8 |
| `options.rotate` | integer | no | Quarter turns clockwise: 0, 90, 180 or 270. min 0; max 270 |
| `options.to` | string | no | Output format. GET /api/v1/tools/image-convert/formats lists the ones this server can write. max length 16 |
| `options.upscale` | boolean | no | Allow making the image larger. Off by default: upscaling produces a bigger file that looks worse |
| `options.width` | integer | no | Target width in pixels. 0 leaves that axis open. min 0; max 20000 |

## Output

A call that works returns `isError: false`, the result as JSON text in `content`, and the same result as an object in `structuredContent`.

| Member | Type | Always present | Notes |
| --- | --- | --- | --- |
| `tool` | string | yes | The tool that ran. |
| `conversion_id` | string | yes | The conversion on the server. |
| `status` | string | yes | `finished`. |
| `outputs` | array of object | yes | One entry for each file written: `path`, `name`, `mime` (when known) and `size_bytes`. |
| `bytes_in` | integer | no | Bytes uploaded. |
| `bytes_out` | integer | no | Bytes written. |
| `note` | string | no | What the conversion says about itself, when it has something to say. |
| `expires_at` | string | no | When the server deletes its copy of the result. |

## Errors

A failed call is not a protocol error: it returns `isError: true` and a `code` the agent can branch on. The ones this tool is likely to meet:

- `invalid_input`: an argument is missing, unknown or out of range, or a file is not readable or is empty. Checked before anything is uploaded.
- `missing_key` and `unauthorized`: `VUKEM_TOOLS_API_KEY` is not set, or the server refused it.
- `missing_ability`: the key lacks `image:convert`.
- `file_too_large`, `conversion_failed`, `timeout` and `result_expired`: the server could not finish or the result was gone before it was downloaded.
- `rate_limited`, `network_error` and `io_error`: a limit, the server could not be reached, or a file could not be read or written.

The full table, with `retry` and `conversion_type`, is in [What a result looks like](/docs/mcp/overview#what-a-result-looks-like).

## Safety

The agent chooses the paths, and the process can read and write anything your user can. The result is written to a temporary file next to `output` and then renamed, so a failed download leaves no partial file. See [What keeps an agent safe](/docs/mcp/overview#what-keeps-an-agent-safe).

## Example

**Ask the agent**

> Convert an image: read `in.png` and write `out.png`.

**The call** (`tools/call`)

```json
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"image-convert","arguments":{"input":"in.png","output":"out.png","options":{"height":1024,"keep_metadata":false,"quality":82,"resize":"fit","to":"webp","width":1024}}}}
```

**The result** (`result`)

```json
{"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"text","text":"{\"tool\":\"image-convert\",\"conversion_id\":\"01JQ8Z5X0K7M3N9P2R4T6V8W0Y\",\"status\":\"finished\",\"outputs\":[{\"path\":\"out.png\",\"name\":\"out.png\",\"size_bytes\":1234}],\"bytes_in\":1500,\"bytes_out\":1234,\"expires_at\":\"2026-01-02T15:09:05Z\"}"}],"structuredContent":{"tool":"image-convert","conversion_id":"01JQ8Z5X0K7M3N9P2R4T6V8W0Y","status":"finished","outputs":[{"path":"out.png","name":"out.png","size_bytes":1234}],"bytes_in":1500,"bytes_out":1234,"expires_at":"2026-01-02T15:09:05Z"},"isError":false}}
```

The values are illustrative: the names and the output path come from your call, the sizes and the id from the run. The member names are exact.

## Next steps

- [Connect a client](/docs/mcp/connect)
- [The MCP tools](/docs/mcp/tools)
- [The API operation behind it](/docs/api/tools.image-convert)
