Background Crop for images with large margins and solid color backgrounds?
A common issue I run into is with product photos. They may have a white or off-white background that is much larger than the actual product (large margins).
It would be great to have a crop mode (e.g. "background crop" with some tolerance factor).
The algorithm could be something like:
- look at the image edges and if the color is consistent around the image edges (within specified tolerance)
- cropping in from each original image edge as long as the crop lines have the same color as the outer image edge (within some specified tolerance)
- tolerance would be relative to the color at the edges of the source image.
- if the source image edges have color variation already outside of the specified tolerance, no cropping should be done.
Example image of a toaster with way-too-big white margins. https://i.imgur.com/33OYPaa.jpg a good background crop would look something like this: https://i.imgur.com/G2vRMN4.jpg notice the background crop will likely change the aspect ratio of the image, so additional resizing/cropping to target size should be calculated after the background crop.
In terms of use case, I would want to be able to say something like:
x100,bc,0 - AFTER background crop with 0% tolerance: 100px high, relative width (resize after crop)
100x,bc,10 - AFTER background crop with 10% tolerance: 100px width, relative height (resize after crop)
100x100,bc,0 - AFTER background crop with 0% tolerance: 100px width, 100px height (resize + second crop after original background crop unless background crop resulted in square aspect ratio)
Does that make sense?
As far as I can tell smart crop won't really do this very well from my testing. It removes some of the background depending on the dimensions you give relative to source dimensions...but isn't really optimized for getting rid of as much background as possible.
For people that deal with a lot of product photography I see this as a super useful functionality.
Example would be generating thumbnails for links or search results on the fly where the margins on the original image would yield way too small product images when sized down to thumbnails with the existing margins.