Live data from Hacker News

The algorithm for a perfectly balanced photo gallery

crispymtn.com

1–10 of 104 posts

Re: The algorithm for a perfectly balanced photo gallery

#6
I just implemented pretty much the same thing from scratch for my wedding gallery¹.

For each row, it tries 3-10 images, sums their aspect ratios, divides the total row width by the sum to get a candidate height, then picks the height that's closest to the average of the existing rows.

To make things look a bit nicer, it rejects candidate rows with the same number of images as the last row.

I might release the code on Github if I can make it modular enough. Currently it depends on jQuery but that's really only for element creation.

¹ http://mattandsophiegetmarried.com, I'm the guy with the waistcoat, purple cravat and massive grin.

Re: The algorithm for a perfectly balanced photo gallery

#7
Maybe I'm missing the point but why is this an achievement? I've seen Google images do this for years (from the backend, sends the users viewport dimensions and then automatically calculates the optimum filling). For years (Warning NSFW!) vusker.com has been doing this client-side in their thumbnail and gallery view. Plus look at the vertically stacked posts from Pinterest.

It seems more a marketing ploy to get attention to the great service chromatic.io is providing?

Re: The algorithm for a perfectly balanced photo gallery

#8
post #7

Maybe I'm missing the point but why is this an achievement? I've seen Google images do this for years (from the backend, sends the users viewport dimensions and then automatically calculates the optimum filling). For years (Warning NSFW!) vusker.com has been doing this client-side in their thumbnail and gallery view. Plus look at the vertically stacked posts from Pinterest. It seems more a marketing ploy to get atten…

Granted, maybe pinterest is a bad example in regards to optimum page filling.

Re: The algorithm for a perfectly balanced photo gallery

#9

I just implemented pretty much the same thing from scratch for my wedding gallery¹. For each row, it tries 3-10 images, sums their aspect ratios, divides the total row width by the sum to get a candidate height, then picks the height that's closest to the average of the existing rows. To make things look a bit nicer, it rejects candidate rows with the same number of images as the last row. I might release the code on…

That looks pretty nice too! Congrats on the wedding!

Re: The algorithm for a perfectly balanced photo gallery

#10

What's just as impressive is the full size view of the image. The background brings the ambient colour of the photo to make it more immersive. Very nice!

I agree, that looks very nice.

I might be wrong here but I think the background is just the picture, although scaled and has got many filters on it.

Post reply on HN