Keep ratio of 2 images
Posted on August 12th, 2008 in Links |
I found a formula for making 2 images proportional on a forum the other day.
The formula is: H1 / W1 = H2 / W2
Example:
if (image1.height > image1.width) {
newWidth = (image1.width / image1.height) * preferredheight;
image1.height = preferredheight;
image1.width = newWidth;
}else {
newHeight = ((image1.height / image1.width) * preferredWidth);
image1.width = preferredWidth;
image2.height = newHeight;
}













