0

I have a set of images that have varying resolution (both width and height) and I'm trying to combine the images into one large image. I would like to minimize the width and height of the final combined image, so find an arrangement where max(combined_width, combined_height) is minimal. The images are rectangular and cannot overlap. Is there an algorithm I could use for this?

Illustration of the problem:

Problem illustration

An example set of image sizes (width, height):

(91, 272) (113, 254) (82, 237) (83, 203) (36, 109) (67, 192) (88, 198) (91, 215) (126, 264) (99, 287) (88, 313) (38, 63)

Mantu
  • 51
  • 5
  • 1
    Possible duplicate of [What algorithm can be used for packing rectangles of different sizes into the smallest rectangle possible in a fairly optimal way?](https://stackoverflow.com/questions/1213394/what-algorithm-can-be-used-for-packing-rectangles-of-different-sizes-into-the-sm) – c2huc2hu Jul 23 '18 at 14:10
  • 1
    @user3080953 Thanks for the link. In the end, given that the algorithms I could try were either slow with large number of images or suboptimal (a lot of empty space in the final image), I decided to calculate the mean image size and scale all images to that size and then create a simple grid that minimizes the final width and height. It introduces some stretching to the images, but it is ok for my purpose. – Mantu Jul 23 '18 at 19:41

0 Answers0