Way to automatically crop given distance from object contours?

XnConvert Multi Platform - Windows, MacOSX, Linux

Moderators: helmut, XnTriq, xnview

Post Reply
naum
Posts: 2
Joined: Tue Jun 17, 2025 11:40 pm

Way to automatically crop given distance from object contours?

Post by naum »

Hi, I need help or advice on how to crop multiple photos along the contour of an object at a given distance from the object. Photo session of a person, 200k photos. Background from dark gray to gray.

Is there a program with AI for mass cropping of photos along the contour of an object? Are there any automatic cropping methods?

I have sets of an object, many photos, and an object in any part of the photo, and I need the AI ​​to understand that this is an object. Dumb cropping is not suitable, since the object is in any part and halfway from the side, then only the top would be cut off to the object. And ideally, I want the AI ​​to remove the background and crop along the object at specified mm from the object. Then I will put these cropped photos in the AI ​​to improve the quality of photos up to 2k.
marsa
Posts: 2
Joined: Tue Jun 17, 2025 6:07 am

Re: Way to automatically crop given distance from object contours?

Post by marsa »

Can you give us a sample image?

I do similar thing, but with stock images with white background - just to standardize the white border size and image dimensions/aspect ratio of multiple images.
Attachments
My setup for crop & add border for objects with white background
My setup for crop & add border for objects with white background
Screenshot 2025-06-18 081208.png (32.67 KiB) Viewed 116 times
User avatar
user0
XnThusiast
Posts: 2441
Joined: Sat May 09, 2015 9:37 am

Re: Way to automatically crop given distance from object contours?

Post by user0 »

naum wrote: Tue Jun 17, 2025 11:49 pm how to crop multiple photos along the contour of an object at a given distance from the object.
Photo session of a person, 200k photos. Background from dark gray to gray.
Photoshop has 'Select subject' functionality and support JavaScript (Photoshop scripting guide)
so you can automate any action in the app

eg Photoshop Auto Crop Script by William Campbell
video, script in binary! format (old source code can be found in topics 1, 2)
naum
Posts: 2
Joined: Tue Jun 17, 2025 11:40 pm

Re: Way to automatically crop given distance from object contours?

Post by naum »

marsa wrote: Wed Jun 18, 2025 5:15 am Can you give us a sample image?

I do similar thing, but with stock images with white background - just to standardize the white border size and image dimensions/aspect ratio of multiple images.
Here are some sample photos for cropping processing.
https://drive.google.com/file/d/1bDrgEr ... sp=sharing
Post Reply