Is there any algorithm for arranging a lot of small images with different dimensions and group them into a larger one? Anyone have any idea from where should i start investigating?
EDIT: Basically i want to make something like this http://www.google.ro/images/srpr/nav_logo27.png in PHP. I'm not really expecting such complexity. I'm gonna use the image as a CSS sprite, if it makes any difference.