I have a collection of different sized squares and rectangles that I want to fit together using PHP into one large square/rectangle. The squares are usually images that I want to make into a montage - but sometimes they are simply math objects.
Are there any PHP algorithms for this and what is this type of thing called?
Update: After more searching I think what I want is called the bin packing problem. However, I would also like to add a certain amount of randomization for certain types of packing problems (like images) to allow human interest.