# Smart Cropping

## Overview

The Image Editing API allows you to automatically crop an image to put the focus on its main subject.

To perform such a smart crop set the parameters:

* `removeBackground` to `false`&#x20;
* `outputSize` to the desired result size and aspect ratio, for example `2000x2000`&#x20;
* `padding` to add some breathing room around the subject, for example `10%`
* (*optional)* `segmentation.prompt` to focus on a specific element of the image, for example `product`  &#x20;

<table data-header-hidden><thead><tr><th align="center" valign="middle"></th><th align="center" valign="middle"></th></tr></thead><tbody><tr><td align="center" valign="middle"><em>(original image)</em></td><td align="center" valign="middle"><em>(result image)</em></td></tr><tr><td align="center" valign="middle"><img src="/files/9igU4Y8Qm81OpF9sfIPo" alt=""></td><td align="center" valign="middle"><img src="/files/tMV8LE4kkBWPV77Ilqb7" alt=""></td></tr></tbody></table>

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 removeBackground=false \
  --form outputSize=2000x2000 \
  --form padding=10% \
  --form segmentation.prompt=product \
  --output result-smart-crop.png
```

<a href="https://try-api.photoroom.com/?removeBackground=false&#x26;outputSize=2000x2000&#x26;padding=10%25&#x26;segmentation.prompt=product" class="button primary">Try it now!</a>

## Examples

<table data-header-hidden><thead><tr><th align="center" valign="middle"></th><th align="center" valign="middle"></th></tr></thead><tbody><tr><td align="center" valign="middle"><em>(original image)</em></td><td align="center" valign="middle"><em>(result image)</em></td></tr><tr><td align="center" valign="middle"><img src="/files/QloNvctZNPrK0zQK0DNR" alt=""></td><td align="center" valign="middle"><img src="/files/Ui15K8XttbsXXswGGdnh" alt=""></td></tr><tr><td align="center" valign="middle"><img src="/files/5TC6YZOqada8cZ56p7Iz" alt=""></td><td align="center" valign="middle"><img src="/files/xARVwuNo4njyO4ytBBV8" alt=""></td></tr><tr><td align="center" valign="middle"><img src="/files/yY0mWozJ1TTf43KjacEg" alt=""></td><td align="center" valign="middle"><img src="/files/j4AJEwwoYzB6XOCGlPD0" alt=""></td></tr><tr><td align="center" valign="middle"><img src="/files/Gi5Gw56TYaVvTfBR5dQE" alt=""></td><td align="center" valign="middle"><img src="/files/FLb9JFVPtwmLRVgl66NF" alt=""></td></tr><tr><td align="center" valign="middle"><img src="/files/re8UXdA9eerfYcM0TpuL" alt=""></td><td align="center" valign="middle"><img src="/files/Wn8BT0S2r9lFy3AjVLKm" alt=""></td></tr></tbody></table>


---

# 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/smart-cropping.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.
