Auto cropping product images
Hi, I've trawled through the tutorials, knowledge base and community questions but can't find the answers to my questions, so I'm hoping somebody can help clarify whether it's possible to do the following.
I want to batch auto-crop product photos so there's padding around the product as seen in the photo below.
Original images will look something like this and be around 3600 x 2700 pixels:
Currently I manually crop each image to a grid like this at 2400 x 1800 pixels:
As the products vary, sometimes the vertical or horizontal padding won't be equal so the top and bottom padding may be 150 pixels but the left and right padding could be, for example, 300 pixels, and the padding in the original images is always different too as the photos are not taken on a tripod.
Is it possible to perform this as an action and if so can it be automated in batches?
Appreciate any help!
Thanks :)
Answers
-
Hi there,
Thanks for reaching out to us! While there isn't a perfect way to handle this in an automated fashion without ever needing to manually intervene, there are some options here.
One is to use
e_trim
, which does exactly what you're looking for. Unfortunately, since this is an automated transformation, combined with the fact that your subject is a very similar color to the background, it won't be perfect. Here's an example of usinge_trim
on your image uploaded to my account: https://res.cloudinary.com/victorli/image/upload/e_trim/v1696550748/screenshot-2022-11-30-at-13-38-27.webpYou can adjust the "strength" of
e_trim
so that it gets more aggressive with the trimming if you'd like. In this particular example, you can trim off a bit more up until aboute_trim:27
before you start cutting off too much.vs.
It may be that the best option for you is to use
e_trim
with background colors that are not similar to the subject. More information aboute_trim
can be found here: https://cloudinary.com/cookbook/trim_photo_backgroundAnother option is to use
g_auto
which, when cropping an image, automatically tries to center on the subject of the image. Here's an example in which I am setting the width of the image to 700px, and cropping automatically: https://res.cloudinary.com/victorli/image/upload/w_700,g_auto,c_crop/v1696550748/screenshot-2022-11-30-at-13-38-27.webpAgain, not perfect, but makes some progress. More information about this can be found here: https://cloudinary.com/blog/new_ai_based_image_auto_crop_algorithm_sticks_to_the_subject
I hope this helps! Please feel free to let us know if you have any questions about this and we'd be happy to assist.
Regards,
Victor
0