For each row, it tries 3-10 images, sums their aspect ratios, divides the total row width by the sum to get a candidate height, then picks the height that's closest to the average of the existing rows.
To make things look a bit nicer, it rejects candidate rows with the same number of images as the last row.
I might release the code on Github if I can make it modular enough. Currently it depends on jQuery but that's really only for element creation.
¹ http://mattandsophiegetmarried.com, I'm the guy with the waistcoat, purple cravat and massive grin.
Congrats on the wedding though.
The photos didn't appear correctly aligned though -- some 70-100px "whitespace" at the right edge of the screen. And resizing the screen removed all content.
edit: I'm using Firefox v22 on Xubuntu.
However if you then resize the window it seems to make all the images disappear (?)