> For the complete documentation index, see [llms.txt](https://docs.photoroom.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.photoroom.com/image-editing-api-plus-plan/file-size-resolution-and-format.md).

# File size, resolution and format

## **Which image formats are supported?** <a href="#q-what-are-the-max-resolution-and-size-of-the-image" id="q-what-are-the-max-resolution-and-size-of-the-image"></a>

For the input and result images, the Image Editing API supports four formats: PNG, JPEG, WEBP and AVIF.

By default, the result image will be in PNG format.

To configure the format of the result image, set the argument `export.format` with one of the following values:

* `png` is the lossless PNG format (biggest file size, zero quality loss, transparency is saved)
* `jpeg` or `jpg` for JPEG format (smaller file size, transparency is ***not*** saved)
* `webp` for WebP format (even smaller file size, transparency is saved)
* `avif` for AVIF format (smallest file size, takes a few seconds longer to create, transparency is saved)

{% hint style="info" %}
JPEG, WebP export with a quality of 90. AVIF uses 75 which has the same or higher fidelity according to [benchmarks](https://tsev.dev/posts/2023-11-10-should-avif-be-the-dominant-image-format/)
{% endhint %}

{% hint style="warning" %}
JPEG format does **not** support transparency.&#x20;

Asking the Image Editing API to export in JPEG while also setting a background color with transparency will result in an error.
{% endhint %}

If you want to give it a try, here's the code to export an image in JPEG format:

{% code overflow="wrap" %}

```bash
curl --request POST \
  --url https://image-api.photoroom.com/v2/edit \
  --header 'x-api-key: YOUR_API_KEY' \
  --form imageFile=@/path/to/your/image.jpg \
  --form background.color=FFFFFF \
  --form outputSize=1000x1000 \
  --form padding=0.1 \
  --form 'export.format=jpeg' \
  --output result.jpeg
```

{% endcode %}

<a href="https://try-api.photoroom.com/?background.color=FFFFFF&#x26;outputSize=1000x1000&#x26;padding=0.1&#x26;export.format=jpeg" class="button primary">Try it now!</a>

And here's the code to export an image in WebP format:

{% code overflow="wrap" %}

```bash
curl --request POST \
  --url https://image-api.photoroom.com/v2/edit \
  --header 'x-api-key: YOUR_API_KEY' \
  --form imageFile=@/path/to/your/image.jpg \
  --form background.color=FFFFFF \
  --form outputSize=1000x1000 \
  --form padding=0.1 \
  --form 'export.format=webp' \
  --output result.webp
```

{% endcode %}

<a href="https://try-api.photoroom.com/?background.color=FFFFFF&#x26;outputSize=1000x1000&#x26;padding=0.1&#x26;export.format=webp" class="button primary">Try it now!</a>

And the code to export an image in AVIF format:

{% code overflow="wrap" %}

```bash
curl --request POST \
  --url https://image-api.photoroom.com/v2/edit \
  --header 'x-api-key: YOUR_API_KEY' \
  --form imageFile=@/path/to/your/image.jpg \
  --form background.color=FFFFFF \
  --form outputSize=1000x1000 \
  --form padding=0.1 \
  --form 'export.format=avif' \
  --output result.avif
```

{% endcode %}

<a href="https://try-api.photoroom.com/?background.color=FFFFFF&#x26;outputSize=1000x1000&#x26;padding=0.1&#x26;export.format=avif" class="button primary">Try it now!</a>

## Preserving the input colour space (`colorSpace: "original"`)

By default the Image Editing API returns results in **sRGB**. Set `colorSpace: "original"` on `/v2/edit` to keep the input image's **own colour space and embedded ICC profile** (e.g. Adobe RGB, Display P3) in the output — preserved with no conversion to sRGB. This applies to **background removal** (including HD): the cutout is returned as a PNG carrying the original ICC profile.

* **Default** (omit `colorSpace`, or `colorSpace=sRGB`): output is sRGB, exactly as before.
* **`colorSpace=original`**: output keeps the input's colour space + ICC profile.

#### When it works

A **pure background removal** (no other edits), with **PNG output**, on an input that has an embedded colour profile.

#### When it returns HTTP 400

`colorSpace: "original"` only applies to a plain background removal that outputs PNG. The request is rejected with a **400** (the error names the conflicting parameter) if it also includes:

* Any operation **beyond background removal** — AI/replacement backgrounds, a background colour or image, shadows, relighting, templates, etc.
* An **output format other than PNG** (e.g. JPG, WebP, AVIF).
* **`export.dpi`**.
* **`keepExistingAlphaChannel`** set to anything other than `never`.
* **`preserveMetadata`** set to an EXIF-subset mode.

```bash
curl -X POST https://image-api.photoroom.com/v2/edit \
    -H "x-api-key: YOUR_API_KEY" \
    -F "imageFile=@product.jpg" \
    -F "removeBackground=true" \
    -F "colorSpace=original" \
    -F "export.format=png" \
    -o cutout.png
```

```json
{
    "error": {
      "message": "colorSpace: \"original\" is only supported when the request is a pure background removal with PNG output. Conflicting parameter: \"background\"."
    }
  }
```

{% hint style="info" %}
If the input image has no embedded colour profile, there's nothing to preserve — the output carries the image's native colour as-is.
{% endhint %}

## **What are the max resolution and size of the image?** <a href="#q-what-are-the-max-resolution-and-size-of-the-image" id="q-what-are-the-max-resolution-and-size-of-the-image"></a>

We recommend limiting images to 25 megapixels for optimal performance.

* **Maximum File Size**: 30MB
* **Maximum Resolution**: 5,000 pixels on the widest side

Images with a larger resolution are supported (if they stay below 30MB), but will be resized down to 5,000 pixels on the widest side.

{% hint style="info" %}
Please note that large images will result in API calls taking a longer time to complete.

If you experience timeouts, we recommend that you try to increase the default timeout of your networking library.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.photoroom.com/image-editing-api-plus-plan/file-size-resolution-and-format.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
