Finding the percentage to scale in img

72 Views Asked by At

I am trying to scale one img based on its size on the screen to a size of max space on my paper. I want to get a percentage so that way I could just plug it into my calculator and easily convert each size of the elements of the img to the proportional size of the space provided. The space on the paper is not proportional to the size of the original img. So the draw img doesn't have to take up the whole space in the space on the paper. The space is just for reference of how much is available.

1

There are 1 best solutions below

6
On BEST ANSWER

I'm not sure exactly what you're looking for, but here's an example problem in this general domain. Suppose you have an original picture of dimensions $W \times H$, and you need it to fit into a space with dimensions $x \times y$.

Then compute $r_1 = x/W$ and $r_2 = y/H$, and find $r = \min\{r_1, r_2\}$. That is the scaling factor of the maximal copy of the original that will fit into the given space. The basic reasoning is that a scaling of $r_1$ will get the picture to fit just right horizontally, while a scaling of $r_2$ will get the picture to fit just right vertically. In order for it to fit in both directions, the picture must be scaled to the minimum of those two.