opendir( DIR, $dir ) or die( "Error opening: $!" );
my @imagefiles = grep { /\.jpg$|\.gif$|\.png$|\.JPG$|\.bmp$/ } readdir(DIR);