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:
removeBackgroundtofalseoutputSizeto the desired result size and aspect ratio, for example2000x2000paddingto add some breathing room around the subject, for example10%(optional)
segmentation.promptto focus on a specific element of the image, for exampleproduct
(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.pngExamples
(original image)
(result image)










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:
removeBackgroundtofalseto keep the original background and apply only the cropreferenceBoxtosubjectBoxto frame the crop relative to the modelsegmentation.modetoignoreSalientObjectso the prompts drive the crop region instead of the most prominent objectsegmentation.prompttogarment,chin,lip,mouth, the parts to keepsegmentation.negativePrompttohead,nose,eye,forehead, the parts to excludepaddingto25pxto add a little breathing room around the subject
(original image)
(result image)


If you want to give it a try, here's the code to reproduce the example above:
Tip: You can chain this with subsequent Image Editing API calls to remove the background, add realistic shadows, or apply further enhancements.
Last updated
Was this helpful?