Title gore sorry, it's hard to describe.
I got an image, which is let's say,
boxHeight = 800
imageHeight = 1000
desiredBoxHeight = 600
requiredImageHeight = ??
If I understand correctly; The image scales proportionally to the size of the box. The box goes from 800 to 600 pixels. So the image goes from 1000 to 1000 * (600/800) = 750 pixels.
requiredImageHeight = imageHeight * (desiredBoxHeight / boxHeight)