Quite often, in programming and dealing with images, it becomes necessary to resize the image without distorting its aspect ratio. Since the width and height of an image is a ratio, we can use the fundamental rule of proportions to resize the image.

This is a basic proportion:

Where is the original image width, is the original images height, is the new width, and is the new height. Since decreasing or increasing the values directly affect the other, this is a direct proportion, as written above.

The fundamental rule of proportions says that we can cross-multiply a proportion.

This allows us to create algebraic equations for solving problems.

Example: If is unknown. After cross-multiplying we need to move to the other side of the formula, so we can get by itself. We do this by dividing both sides by .

The (s) on the right side of our formula cancel giving us:

Now, let’s work it out the other way around and find . again, our cross-multiply formula:

We need to get on one side by itself, so this time we will divide both sides by :

The (s) on the left side cancel, leaving us with:

So, our formulas for calculating a new width or height for an image while maintaining the aspect ratio is

When the width () is known and the height () is unknown:

And when the height () is known and the width () is unknown:

NOTE: Keep in mind that the formula will not always give you a whole number, and you will need to round to the nearest whole number.

### Like this:

Like Loading...