I like using [man]glob/man, but otherwise essentially the same thing:
$files = glob($directory)
foreach($files as $file)
{
if(is_file($file))
{
$size = getimagesize($file);
if($size !== false)
{
printf("<img src='$file' alt='' width='%d' height='%d' />\n", $size[0], $size[1]);
}
}
}