2D Bin-packing 3:4, 4:3, and 1:1 shapes (photos)

216 views Asked by At

Does an algorithm exist for this or can someone point me in the right direction?

I have a prioritized set of users with images. Each image may 3:4, 4:3, or 1:1 in ratio. Each user has a different set of prioritized images with different ratios. I want to produce an infinite scrolling x-y axis collage with zero gaps. While 2D bin packing of different shapes is NP-hard, there are a few "cheats" that may make this easier:

  1. There should be 3 sizes of each shape: Big, Medium, and Small (e.g., 3:4 will have 3:4 Big, 3:4 Medium, and 3:4 Small).
  2. The entire collage does not need to fit into any shape as the viewer will never see an edge (it's infinite scrolling)
  3. Any rectangular, non-square shape can be adjusted +/- 10 pixels. We will enlarge and crop the opposite side (width or length) to accomodate the new shape. This makes clearing gaps of up to 20px possible.
  4. There needs to be a fixed border of between 15-25px between every shape. This border size cannot change.

Using these parameters, I was able to visually construct a grid of shapes. I started with these 9 sizes: http://cl.ly/image/08373b0r311L and a 20px border. Then, I made a collage (http://cl.ly/image/3h462O3i3k47) using "super patterns" that fit in super large rectangles. Note that the red shapes are 3:4 shapes that were padded by +/- 10px. In this case, I only had to pad the 3:4 images.

Thanks for any help you guys can provide :)

0

There are 0 answers