When I add a caption to an image it gains a border and some text underneath it. I want to have multiple pictures with the same border size. The problem is if I do it with different images of different sizes, the size of the border is, of course, different as well. And if I resize the border to fit the size I want it to be the image gets distorted and does not keep its ratio. Is there a way to automatically resize the image so it fits the border but still keeps its ratio? The image would then fit horizontally or vertically (or perfect if it has the same ratio as the border).
I already tried to add margins to the image inside the border but for all the images I have it would take very long and I think there must be a more elegant solution.