I have a program that will calculate the minimal area taken by fitting rectangles together.
Input: Rectangles of different height and width.
Output: One rectangl
http://www-rcf.usc.edu/~skoenig/icaps/icaps04/icapspapers/ICAPS04KorfR.pdf
Apparently this problem is harder than it looks at first. It's an interesting algorithm, since first it guesses a solution and then improves on it, so if you don't want to wait for the optimal solution, you can just run it for a set number of iterations to get an approximate solution (the longer you run it, the better the approximation).