TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

JQuery plugin to arrange images using knapsack algorithm

46 点作者 sushi大约 13 年前

8 条评论

vog大约 13 年前
Great idea! However, the term "knapsack algorithm" is quite misleading.<p>There is the "knapsack problem", but there are various different algorithms to solve it. Which of those has been used? Why this and not another algorithm? All those questions are concealed behind the squishy term "knapsack algoritm".
评论 #3882999 未加载
omgmog大约 13 年前
Whipped up a quick example, it seems to re-order the images in a way to fit the most it can on each row given the width constraints and the width of each image - <a href="http://jsfiddle.net/vXbCY/" rel="nofollow">http://jsfiddle.net/vXbCY/</a>
评论 #3882997 未加载
zsherman大约 13 年前
I wish there was a quick link to an example.
评论 #3882979 未加载
riffraff大约 13 年前
what is the "knapsack algorithm" ?<p>I understand how arranging images may be a "knapsack problem" but I can't pinpoint what <i>the algorithm</i> is supposed to be.
评论 #3883033 未加载
jmathai大约 13 年前
I believe this is similar to the layout used for G+ photos and Flickr's new justified view. Am I right?<p>We adapted the script below for <a href="http://current.openphoto.me/photo/list" rel="nofollow">http://current.openphoto.me/photo/list</a> --- curious to check this out as well.<p><a href="http://www.techbits.de/2011/10/25/building-a-google-plus-inspired-image-gallery/" rel="nofollow">http://www.techbits.de/2011/10/25/building-a-google-plus-ins...</a>
评论 #3883466 未加载
moe大约 13 年前
Aren't most (all?) knapsack solvers greedy?<p>That doesn't seem like a good idea just to arrange some images (battery killer?).
gauravsc大约 13 年前
Plugin co-author here: One more possible extension of this algo would be to use value of each image equal to the weight of each image. This would ensure best fit and would be one more way to make things look beautiful and arranged.
dangoldin大约 13 年前
Pretty interesting stuff. Have you heard of the Isotope jQuery library? It does something similar.<p>How is the performance on this one?
评论 #3884133 未加载