I'm looking for a tool that will layout images into grids dynamically without altering their proportions. The purpose would be to make cutting image printouts much faster for scrapbooking. I know a lot of websites can lay out images dynamically, taking each image size into consideration. Is it possible to run a commandline tool to achieve something like this? If possible, a grid without borders would be much better.
There is an extension for photoshop that achieves something like this
However, from what I can see, other options in Linux aren't dynamic and require that all images have the same aspect-ratio. It would be ok if there is a little space left over at the end of a page (as in the example). The priority is to maintain each image's aspect ratio whilst using as much space as possible on the page.
An example:

