this snippet reads a given directory and returns an array of the images found. gets some information about the images as well .

drop this in any directory and replace the path to the folder with ./ and specify the files you want to show.
you get a list of all files which mach the criteria.

list image folder” makes use of the built-in PHP functions opendir( ), readdir( ), in_array( ), strtolower( ), end( ), explode( ), is_array( ), sort( ), count( ), getimagesize( ) and ceil( ).

01 <?php
02 
03 // the directory, where your images are stored
04 $imgdir = '/Users/lixlpixel/Pictures/pics/';
05  
06 // list of file extensions you want to show
07 $allowed_types = array('png','jpg','jpeg','gif');
08  
09 $dimg = opendir($imgdir);
10 while($imgfile = readdir($dimg))
11 {
12     if(in_array(strtolower(end(explode('.',$imgfile))),$allowed_types))
13     {
14         $a_img[] = $imgfile;
15     } 
16 }
17  
18 // sort image array
19 if(is_array($a_img)) sort($a_img);
20  
21 // total image number
22 $totimg = count($a_img);
23  
24 for($x = 0; $x < $totimg; $x++)
25 {
26     $size = getimagesize($imgdir.'/'.$a_img[$x]);
27  
28     // do whatever
29     $halfwidth = ceil($size[0]/2);
30     $halfheight = ceil($size[1]/2);
31     echo 'name: '.$a_img[$x].' width: '.$size[0].' height: '.$size[1].'<br />';
32 }
33  
34 ?>