in reply to Manipulating Images (height and width)

Well, I use Image::Magick for that
Example:
my $thumb= new Image::Magick; open(IMAGE, "</path/$photof"); $thumb->Read(file=>\*IMAGE); close(IMAGE); $thumb->Resize(geometry=>'120X90'); $thumb->Write("/path/thumb_$photof");

Of course, what is missing in there for your usage is simply a:
my ($height,$width) = $thumb->Get('width','height);

before the resize, and add there your checks.
(the last part is untested).

Michalis