Here's a nice little teaser for those of you who are good at solving maths problems.
If I have two pictures that I can resize (A & B), that I wish to place side by side in an area that has a certain width (C), and the two pictures each have a different aspect ratio. How do I work out what width each picture must be, for their heights to be the same and the width of the area where they are, to be filled. The aspect ratio of each picture must be maintained.
I think I might have it...
Picture width A = C / (aspect ratio (A) + aspect ratio (B)) * aspect ratio (A)
Picture width B = C / (aspect ratio (A) + aspect ratio (B)) * aspect ratio (B)
Of course you only need to work out the width of one picture, as subtracting that width from C will give you the width of the other picture.
I'll do an example as proof...
As I want to fill the entire width of where my pictures are going, then that width is 100%, so C is 100%...
and picture A has an aspect ratio of 0.75. (750px wide, 1000px high)...
and picture B has an aspect ratio of 3. (1000px wide, 333px high).
Picture width A = 100% / (aspect ratio (A) + aspect ratio (B)) * aspect ratio (A)
100 / (0.75 + 3) * 0.75 = 20
Picture A width = 20%
To get the width required for picture B, just subtract the width of picture A (20%) from the area width C (100%), or run the formula...
Picture width B = C / (aspect ratio (A) + aspect ratio (B)) * aspect ratio (B)
100 / (0.75 + 3) * 3 = 80
that gives us 80% for picture B.
Width for picture A = 20%
Width for picture B = 80%
Ta-da!
Here is the final formula...
Anyone for aspirin? 8 )