# Auto Crop Images

Automatically crop an image on a solid background color.

Using an AI coding agent?

Install the [`sirv-dynamic-imaging`](https://www.skills.sh/sirv/image-optimization-skill/sirv-dynamic-imaging) skill, and your agent can build these image URLs for you. Ask in plain words, such as “Serve our product photos as 800px WebP.” [See all 8 skills](/help/rest-api/sirv-skills-for-ai-agents/)

Autocrop with edge detection is useful for achieving a uniform look for your images, for example to standardize ecommerce product images.

Try it

![Original image](https://demo.sirv.com/lacoste.jpg?w=800)

Original

![Image with the options applied](https://demo.sirv.com/lacoste.jpg?crop.type=trim)

With options

Crop type

trimpoiface

Padding X

px%

Padding Y

px%

https://demo.sirv.com/lacoste.jpg**?crop.type=trim**

[](https://demo.sirv.com/lacoste.jpg?crop.type=trim)

## Trim image

To remove the whitespace around an object, set crop.type to trim:

`https://demo.sirv.com/trainer-grey.jpg?crop.type=trim`

![Original image, not cropped](https://demo.sirv.com/trainer-grey.jpg?h=230&text.text=original&text.color=black&text.font.size=16&text.position=northeast)

![Autocropped image](https://demo.sirv.com/trainer-grey.jpg?h=230&crop.type=trim&text.text=cropped&text.color=black&text.font.size=16&text.position=northeast)

Increase the space between the object and the image edge by adding padding with crop.pad.x and crop.pad.y. This example adds 15% padding:

`https://demo.sirv.com/trainer-grey.jpg?crop.type=trim&crop.pad.x=15%&crop.pad.y=15%`

![Autocropped image with 7% padding](https://demo.sirv.com/trainer-grey.jpg?crop.type=trim&w=400&crop.pad.x=15%25&crop.pad.y=15%25)

Change the padding values to give the product more or less space around it.
