Check whether an image is proportional to a given one

144 Views Asked by At

I wonder how can I test whether the size of an image is proportional to $250\times 167$.

For example, I have an image size of $1000\times 668$ and would like to see if it is proportional to $250\times 167$.

How can I do this check?

1

There are 1 best solutions below

0
On BEST ANSWER

If this task comes up in the context of programming, you may want to avoid division in order to keep everything of integer type (thus avoiding comparison of floats). In this case, instead of comparing $$ \frac{1000}{668} \overset{?}{=} \frac{250}{167} $$ check whether $$ 167\cdot 1000 \overset{?}{=} {250}\cdot 668 $$ That is,

if (167*width == 250*height) ....