I'm processing my images to resize them, and when the width is minor than the height I open the image with Gimp to make a simple transformation. I read all the images in my directory with:
Your question is perfectly valid, but just as an FYI, the image gallery and resizing thing is one of the world's most reinvented wheels. Maybe people just like coding Perl, and nothing is wrong with that... but I suggest you check out igal or if you want, the ImageMagick modules, or maybe even just the ImageMagick convert utility. Plenty of solutions already out there.