title: Photo collage algorithm
body: <p>I am trying to build a script that will dynamically arrange photos like a collage very similar to what is done on <a href="http://lightbox.com/explore#spotlight" rel="noreferrer">http://lightbox.com/explore#spotlight</a>.</p>
  
  <p>I can off course write code that would handle each case with different sets of photos but I would prefer to have an algorithm that would be able to handle any number of photos.
  The algorithm explained here <a href="http://www.hpl.hp.com/techreports/2008/HPL-2008-199.pdf" rel="noreferrer">http://www.hpl.hp.com/techreports/2008/HPL-2008-199.pdf</a> in chapter 4 seems very similar to what I need to do.
  In my case the vertical and horizontal ratios would always be the same. I would have a defined a bounding box and how many levels each node could get split. The bounding box would have the same ratio of a horizontal photo. If the algorithm can't fit all images I would go back one level and leave it there or pick another photo from a pool of available photos.</p>
  
  <p>My question is very similar to this one <a href="https://stackoverflow.com/questions/7931819/algorithm-arrange-images-on-screen">Algorithm Arrange images on screen</a> but I am not sure how to move forward. Any further guidance or pseudo code would be very helpful.</p>