Sort images by height

I have a photo gallery dynamically generated with PHP. The images are all different heights so when they are displayed, the page layout doesn’t look very good.
Is there any way to display the images by height?

When I upload my photos I resize them and put them onto a set size background and this means they always line up verticaly and horizontaly.

I have just realised I may have made myself a problem as the photos are jpg with the background the same colour as the the page; if I change the page colour the old background will show up!
I suppose I could save them as png and have a transparent background.

You want
to sort the images by hieght before you generate the page?

  • or -
    to resize the images so they fit the design?

The images are already sized when they are uploaded. When they are called from the database onto the page, I would like to sort by height.

However, if you have other ideas, I’d be glad to hear them.

How about adding a SORT BY name of the height field here to the query?

As Mittineague says you could add an extra column and use getimage_size() on upload to add the height to the database.

I suppose you could also get all the images into an array and then loop through the array finding the image heights and sort by the height although this would probably not be very effecient.