This problem is related to programing, for which I am searching an optimal solution.
Problem: I have some images in different height to width ratios. I want to make them in ratios of 1:1 or 3:4 or 4:3, by adding white space. I want to add as little white space as possible, to make it in any of the 3 given ratio. I never want to reduce.
Currently my solution is to create 3 new images for 3 given ratios and then checking for which the program needed to add the least no. of pixel. I then go with that. However currently I am adding pixel to only one side, which I have found is not good and in some cases adding pixel to both the side reduces total no. of white pixel added.
I also have tried searching google, but I don't know what this problem is called i.e what to search for. Hence I am here seeking an insight from you.
I hope the solution to this problem will be with in the limits of high school Maths as anything beyond it, will make the solution harder to implement.
I am afraid, that the solution does boil down essentially to creating the three images - or at least their sizes, and test.
If the original is $x\times y$, then the smallest fitting $1:1$ is clearly $$\max\{x,y\}\times\max\{x,y\}.$$
For the smallest fitting $4:3$ ratio, let $x'=\cdot\lceil x/4\rceil$, $y'=\cdot \lceil y/3\rceil$ and take $$4\max\{x',y'\}\times 3\max\{x',y'\}.$$
Similarly, for the smallest fitting $3:4$ ratio, let $x'=\cdot\lceil x/3\rceil$, $y'=\cdot \lceil y/4\rceil$ and take $$3\max\{x',y'\}\times 4\max\{x',y'\}.$$
Pick the format that leads to the smallest product.