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

  • outputSize to the desired result size and aspect ratio, for example 2000x2000

  • 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

(original image)

(result image)

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

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

Try it now!

Examples

(original image)

(result image)

Last updated

Was this helpful?