Version: .2
Type: Full Script
Category: Graphics
License: GNU General Public License
Description: This page makes a table that gives the name of each image in your image folder; gives the size and type of the image; shows the image itself is shown full-size. To use this page, save the code as a .php file outside your image folder.
<? /* Bill Pellowe, March 7, 2001 This page makes a table that groups the following information: * gives the name of each image in your image folder * gives the size and type of the image * shows the image itself is shown full-size To use this page, save the code as a .php file outside your image folder. Credits: the part that lists files in a directory is modified from an example in Meloni's book, see http://www.thickbook.com/books */ /* If your image bin is not named "images", change the name below. */ $dir_name = "images"; $dir = opendir($dir_name); // start the table: $file_list = "<table>"; while ($file_name = readdir($dir)) { // skip documents: if (($file_name != ".") && ($file_name != "..") && (!preg_match("/.htm/i", "$file_name")) && (!preg_match("/.php/i", "$file_name"))) { $file_list .= "<tr><td width=250><ul> <li>name: <strong>$file_name</strong><br>"; $image_file = "$dir_name/$file_name"; $image_size = getimagesize($image_file, &$image_info); while(list($key, $value) = each($image_size)) { // make the output easier to read switch($key){ case "0": $key = "<li>width: "; break; case "1": $key = "<li>height: "; break; case "2": $key = "<li>type: "; break; case "3": $key = "<li>string: "; break; case "bits": $key = "<li>bits: "; break; case "channels": $key = "<li>channels: "; break; case "mime": $key = "<li>mime: "; } $file_list .= ($key . $value . "<BR>n"); } // close that part of the table and make the next one for the image $file_list .= "</ul></td><td> <img src="$dir_name/$file_name" $image_size[3]> </td></tr><tr><td colspan=2><hr></td></tr>"; } } // finish the table $file_list .= "</table>"; closedir($dir); ?> <html> <head><title>List of images</title></head> <body background="rulerbackground.gif"> <h1>The images in "<? echo "$dir_name"; ?>"</h1> <? echo "$file_list"; ?> </body> </html>