Tiled gallery of images without empty spaces

I have a set of images that have different widths and heights, their height to width ratios are not the same. Is it possibly to make a tiled gallery of these images without any space between rows or columns ie. with completely 100% fill a div with images using only CSS? Leaving space on the last row would be fine but it would be better to have none.

Otherwise I have to use Javascript to make some kind of mosaic row column sorter that adjusts image widths and heights to fill rows and columns. I could use equal row heights and multiple spanning containers in some areas.

So my question is, is this layout possible with only CSS or do I have to use JS?