Is there a way of resizing images of any shape or size to say [500x500]
but have the image's aspect ratio be maintained, levaing the empty space be filled with white/black filler?
So say the image is [2000x1000]
, after getting resized to [500x500]
making the actual image itself would be [500x250]
, with 125
either side being white/black filler.
Something like this:
Input
Output
EDIT
I don't wish to simply display the image in a square window, rather have the image changed to that state and then saved to file creating a collection of same size images with as little image distortion as possible.
The only thing I came across asking a similar question was this post, but its in php
.
Best Answer
Not fully optimized, but you can try this:
EDIT handle target size that is not
500x500
pixels and wrapping it up as a function.