| AND OR | string words | *

image handling

|

list image folder


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.



full source of list image folder [ line 1 - 23 ] | download list image folder

1    <?php
2   $imgdir '/Users/lixlpixel/Pictures/pics/'// the directory, where your images are stored
3   $allowed_types array('png','jpg','jpeg','gif'); // list of filetypes you want to show
4   $dimg opendir($imgdir);
5   while($imgfile readdir($dimg))
6   {
7    if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
8    {
9     $a_img[] = $imgfile;
10     sort($a_img);
11     reset ($a_img);
12    } 
13   }
14   $totimg count($a_img); // total image number
15   for($x=0$x $totimg$x++)
16   {
17    $size getimagesize($imgdir.'/'.$a_img[$x]);
18    // do whatever
19    $halfwidth ceil($size[0]/2);
20    $halfheight ceil($size[1]/2);
21    echo 'name: '.$a_img[$x].' width: '.$size[0].' height: '.$size[1].'<br />';
22   }
23   ?>



6 hits by 5 users in the last 30 minutes.