# AI Uncrop

## Overview

AI Uncrop reconstructs the missing parts of the main subject using only the visible portion.&#x20;

If the edges of the main subject are clipped, they are seamlessly extended to restore the full form.

To uncrop an image, set the argument `uncrop.mode` to the value `ai.auto` and `removeBackground` to `true`:

|                                                                                                  *(original image)*                                                                                                  |                                                                                                  *(uncropped image)*                                                                                                 |
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2FQ7eExtO3Lrs1OkT53EnL%2Fpasta.webp?alt=media\&token=0c6807d7-58e6-4582-852f-7c40d87ad5f1) | ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2Fbi6AaxqPwkC8YGlVo1Xz%2Fimage.webp?alt=media\&token=8dea902a-c8a0-491f-8710-dc3efc433623) |

AI Uncrop works automatically:

* there’s no need to specify new dimensions or which edges to uncrop
* when no edges are cropped, the main subject will not be modified (i.e. AI Uncrop will be a no-op)

{% hint style="info" %}
AI Uncrop is different from [AI Expand](https://docs.photoroom.com/image-editing-api-plus-plan/ai-expand): AI Uncrop focuses specifically on the main subject of the image.
{% endhint %}

If you want to give it a try, here's the code to reproduce the example above:

```bash
curl --request POST \
  --url https://image-api.photoroom.com/v2/edit \
  --header 'x-api-key: YOUR_API_KEY_HERE' \
  --form imageFile=@/path/to/image.png \
  --form uncrop.mode=ai.auto \
  --form removeBackground=true \
  --output result-ai-uncrop.png
```

<a href="https://try-api.photoroom.com/?uncrop.mode=ai.auto&#x26;removeBackground=true" class="button primary">Try it now!</a>

{% hint style="warning" %}
`removeBackground` may **not** be set to false: AI Uncrop always has to be combined with background removal.&#x20;

The API will later start enforcing this.
{% endhint %}

## Which resolutions are supported?

By default, AI Uncrop will produce outputs at a resolution of 1K (`1024x1024`).

Output resolutions of 2K and 4K are available for Enterprise plans:

<div><figure><img src="https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2FBMkdN07CxzvGkjoDcSOi%2Fimage.jpeg?alt=media&#x26;token=c5577888-b2ca-4965-8964-83b9f9ece8e7" alt=""><figcaption><p><em>(original image)</em></p></figcaption></figure> <figure><img src="https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2FgotQlQKxnF3c0wkTJdRI%2Fresponse.png?alt=media&#x26;token=ed63cf71-3865-4466-80b8-81dcf32139e2" alt=""><figcaption><p><em>(default 1K output)</em></p></figcaption></figure> <figure><img src="https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2FhaIc7wnpKl2jP4nogdrR%2Fresponse-4k.png?alt=media&#x26;token=eb1ca38f-9cb0-4003-b804-b5144bd73e5f" alt=""><figcaption><p><em>(4K output)</em></p></figcaption></figure></div>

{% hint style="info" %}
Make sure to click on the images to see them in full resolution.
{% endhint %}

If you're interested to use 2K or 4K resolution, please [contact our team to book a demo](https://www.photoroom.com/contact-sales?utm_source=apidocumentation\&utm_medium=enterprisegated).

<a href="https://www.photoroom.com/contact-sales?utm_source=apidocumentation&#x26;utm_medium=enterprisegated" class="button primary">Book a demo</a>

## Additional Parameters

### **`uncrop.seed`**

If you make several calls to the Image Editing API with the same image, you will notice that it will generate a different uncropped subject every time.

In order to reduce the randomness, you can set a fixed value for the seed that the API's random generator will use. The value of the argument `uncrop.seed` can be any positive integer.

If you provide a value for `uncrop.seed`, then the API should produce similar-looking subject uncroppings for the same image.


---

# Agent Instructions: 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:

```
GET https://docs.photoroom.com/image-editing-api-plus-plan/ai-uncrop.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
