Just as the title explains.
I need to determine how many images from a collection of images I can place in a div, that is for example 100px x 100px and the width and height of each image.
I've been trying to figure the algorithm out for this but my brain is fried.
What I have so far (JavaScript) is to take the width + height (minus padding) / the number of images I have, so let's say I have 13 images to place in 100x100 I can place a maximum of 4, for example, but how do I determine the height (width will be 100px) for each image to make the proportionally fit?
Update
Okay, I have 20+ images that I want to display in a 100x100 block without cutting off images on either the left or right. So, how do I determine, via code that I can only display 4 images, each of 25px x 25px. How do I determine the appropriate width*height of 4 images to fit optimally within 100*100 .