TITLE: Value to divide an number to be less than x
QUESTION [0 upvotes]: On my platform, I have user submitted images that vary in sizes. 
I want the width to never be above 250px. 
So if an image has 1000px width, and 500px height, in order to get it to 250px, I need to divide the width/height with 4. 
What calculation do I need to do to get this particular value?
For example, I have these images:
3299x1000
740x339
2840x2000

How do we get the divide value so all widths equal 250?

REPLY [3 votes]: I assume you're not very much into maths by the phrasing of your question: so I'll keep it simple. You want a value $x$ such that
$$\frac{\text{image width}}{x}=250$$
this means, by doing the most basic arithmetic:
$$x=\frac{\text{image width}}{250}$$
To get the new height we now just have to do
$$\text{new height}=\frac{\text{image height}}{x}$$
which we can also calculate by substituting our expression for $x$:
$$\text{new height}=250\times \frac{\text{image height}}{\text{image width}}$$
be sure to check your image isn't already smaller than 250px because you probably don't want to scale it up.

REPLY [1 votes]: For a given width $w$, you want: $$\frac{w}{x}\leq 250$$
This is equivalent to: $$\frac{w}{250}\leq x$$
Thus, take the given width, and divide by 250. If you want your scaling factor to be a whole number, round up. If that’s not important, leave it alone. As long as the number you divide by is at least $\frac{w}{250}$, you should be fine. :)

REPLY [0 votes]: For each of the images, divide the width by 250. This is the factor you need to divide your height by to keep the aspect ratio. The width you can now just change to 250.
{"set_name": "stack_exchange", "score": 0, "question_id": 2469009}