If you have a photo that is 1600 x 1200 pixels, but your website only has space for a photo 400 pixels wide. To find the new height of your photo — while preserving the aspect ratio — you would need to do the following calculation:
original height / original width x new width = new height
1200 / 1600 x 400 = 300