I’d like to share with you a jQuery plugin I wrote that allows me to turn a canvas into a collage of randomly sorted images.

The problem I ran into was the different aspect ratios.

I don’t know if a collage is possible using a pure css solution, but if you have any suggestions I welcome them! If you just start float’ing images together you get a lot of ugly whitespace. Obviously if you knew the image dimensions before hand then you could write some css to handle all the images.

The algorithm treats the entire canvas like a matrix of rows and columns and fill up the first column. When I reach the bottom row of the canvas I start the next column. If I remember the positioning of the last column of images I know approximately where to put my next column of images. If you want to see the source code just start with this page.