
Which fills a lot less of the canvas than this image:

What I'd like to do (and I hope it's possible) is to process each image in the batch, and for each one identify the side of the image with the least amount of white space between the canvas edge and the outermost non-white element of the photo (e.g. the bottom of the chair legs in the above images), and then apply this white space 'distance' to the other 3 sides. I'm perhaps not super clear in my description, or at the very least not familiar with the technical terms relevant to what I'm looking to do. But in essence I'm looking to automatically transform the first image above into something like this, i.e. adjust the canvas size so that the subject of the image takes up roughly the same proportions of the canvas across all images in my batch.

Thanks in advance!