Reputation: 724
There are several images in folder . I want to fit as many images as possible from the folder into an html page. The images will be selected at random and will have different width & height. I don't want the dimension of the images to change.
How can this be accomplished ?? is this doable with JavaScript ? This looks pretty complicated to me . is there a simple way of doing this via some other method (server side)?
thanks
Edit: so basically we have a room in which we want to pack as many boxes as we can , the boxes all have different size and cannot be stacked over one another..
Upvotes: 2
Views: 195
Reputation: 1103
It would be doable but more difficult I think in JavaScript,
You could use a server side language like PHP to do it like this:
<img/>
elements with a basic html layout surrounding it or an empty layoutIf you could elaborate some more about the details of the page (kind of layout , etc.) I might be able to provide a more specific answer.
Hope this helps.
Update:
It's quite easy to do in php, if you would do it in javascript I would imagine the approach being something like this:
<img width="" height =""/>
elementsUpvotes: 0
Reputation: 7728
This sounds like the bin packing problem:
http://en.wikipedia.org/wiki/Bin_packing_problem
http://mathworld.wolfram.com/Bin-PackingProblem.html
Upvotes: 1