It's nice to see Image::Size getting some play :-)
Rather than rely on the file name's extension, you could just loop over all the files through the imgsize call. Those that don't map to a known image type will return an error of the form "Data stream is not a known image file format" in the third element of the returned array. If it is an image, the 3-letter acronym for the type will be in the 3rd element. You could then actually note which files are images, but not displayable by browsers (such as TIF, BMP, etc.).
OR, if you aren't interested in files that are not GIF, JPG or PNG, you could eliminate the use of $width and $height completely, by using the attr_imgsize call:
use Image::Size 'attr_imgsize';
...
$q->img({-src => $image, attr_imgsize($image))
--rjray |