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.
Photomontage is the process and the result of making a composite photograph by cutting, gluing, rearranging and overlapping two or more photographs into a new image.
In the field of photographic imaging, a photographic mosaic, also known under the term Photomosaic, is a picture (usually a photograph) that has been divided into (usually equal sized) tiled sections, each of which is replaced with another photograph that matches the target photo.
Grouping lets you rotate, flip, move, or resize all shapes or objects at the same time as though they were a single shape or object. You can also change the attributes of all of the shapes in a group at one time, such as adding a shape fill or effect, or an effect to a picture.
Generally it is hard computational problem, but approximate solutions exist.
Edit: Related question Packing rectangular image data into a square texture
Using an optimization algorithm could be an overkill for your problem. Coding an optimization algorithm will require a lot of pre-study. Even implementing a ready library could be a big problem to tackle.
You can devise a heuristic, by yourself:
Use the large image's width and height as your input.
Think of it as if you fill up each row and continue to the next row once the row is filled up.
And start inserting images one by one.
If you use an algorithm the final image will be more optimized. Smaller in size. But the difference would not be much different if your images do not vary a lot in dimensions.
If your image dimensions do vary a little, order them according to their most varying dimension (either width or height). Then start inserting the images in that order.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With