Well, you could look into the dir class, or use [man]opendir[/man] which you can then [man]readdir/man the directory....
As for the image, during your loop of items in the directory, just before it set a counter ($i) equal to 0, then increment it on the loop. In the loop, check to see if $i is equal to 0, if it is, show that image, if not, skip showing the image.