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

# 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>

### Faceless / Headless Crop

Some marketplaces require on-model imagery to be anonymized: the model's face must be cropped out, just below the nose, so the listing doesn't rely on a recognizable likeness.

To produce a faceless crop, set the parameters:

* `removeBackground` to `false` to keep the original background and apply only the crop
* `referenceBox` to `subjectBox` to frame the crop relative to the model
* `segmentation.mode` to `ignoreSalientObject` so the prompts drive the crop region instead of the most prominent object
* `segmentation.prompt` to `garment,chin,lip,mouth`, the parts to keep
* `segmentation.negativePrompt` to `head,nose,eye,forehead`, the parts to exclude
* `padding` to `25px` to add a little breathing room around the subject

<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/RZS9pePWLXFdCcM3PvR4" alt="" data-size="original"></td><td align="center" valign="middle"><img src="/files/WRqALoN9gRXU1b81mdFx" alt="" data-size="original"></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.jpg \
  --form removeBackground=false \
  --form referenceBox=subjectBox \
  --form segmentation.mode=ignoreSalientObject \
  --form 'segmentation.prompt=garment,chin,lip,mouth' \
  --form 'segmentation.negativePrompt=head,nose,eye,forehead' \
  --form padding=25px \
  --output result-faceless-crop.png
```

<a href="https://try-api.photoroom.com/?removeBackground=false&#x26;referenceBox=subjectBox&#x26;segmentation.mode=ignoreSalientObject&#x26;segmentation.prompt=garment%2Cchin%2Clip%2Cmouth&#x26;segmentation.negativePrompt=head%2Cnose%2Ceye%2Cforehead&#x26;padding=25px" class="button primary">Try it now!</a>

**Tip:** You can chain this with subsequent Image Editing API calls to remove the background, add realistic shadows, or apply further enhancements.


---

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