How to optimize the space in a A4 sheet?
I need to put many pictures into a sheet (A4) but I need an algorithm to op开发者_开发知识库timize the space used in order to put the maximum numbers of possible images into the sheet.
That's quite a generic problem... if there are no assumptions at all on the dimensions of the images, your problem is exactly the knapsack algorithm, two-dimensional.
You could try to calculate all combination of the images on the sheet. If this is too time intensive you can begin with the biggest images and then try different positions of the smaller images this should let you calculate a good arrangement in a fairly small amount of time.
精彩评论