I made this script to create thumbnails for images in a directory that already has existing thumbnails in it. It will make a list of all images bigger than 100px X 100 px. Smaller images are ignored. For the bigger images, thumbnails with links to the images are created. The results are paginated - 25 thumbs per page. Title, header and table of contents are created automatically.

The script can also select images at random ($self?rand=full) for a Random Slide Show ($self?img=slideshow) or random thumbs ($self?rand=thumb)

To use, transload http://eclecticdjs.com/mike/temp/ball/thumbs.txt and rename it to .php. If you want to change the number of thumbs per page, change the variable $per_page at the top.

END; #### What page? if ( $_GET[page] ) { $page = $_GET[page]; } else { $page = 1; } $dir = getcwd(); $dir = explode( "/", $dir ); $dir = array_pop( $dir ); $title = "Images in $dir - Page $page"; if ( $_GET[img] == "describe" ) { $title = "Description of Thumbnailer"; } #### find all images in directory #### foreach (glob("{*.jpg,*.JPG,*.jpeg,*.JPEG,*.gif,*.GIF,*.png,*.PNG}", GLOB_BRACE) as $filename) { $array_1[] = $filename; } #### Filter out existing thumbs foreach( $array_1 as $temp) { # Find their size list( $width, $height ) = getimagesize($temp); if ( $width>1 && $height>1 ) { $images[] = $temp; } } asort($images); #### How many pages? $num_images = count( $images ); $pages = ceil($num_images/$per_page); ########################### function thumb( $img) { try { $image = new Imagick("$img"); $image->thumbnailImage(100, 100, TRUE); } catch ( exception $e ) { echo "
ERROR: img must be an image
"; exit; } header('Content-type: image/jpeg'); echo $image; exit; } ############## if ( $_GET[img] ) { if ( $_GET[img] == "slideshow" ) { echo ""; echo ""; echo "Slide Show"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"; echo ""; echo "
"; echo ""; echo ""; echo ""; exit; } if ( $_GET[img] == "describe" ) { echo "$describe"; exit; } $img = trim($_GET[img]); thumb($img); exit; } ########################### ########################### function rand_img( $type, $array ) { shuffle($array); $img = array_pop($array); if ( $type == "full" ) { header("location:$img"); exit; } if ( $type == "thumb" ) { thumb($img); header("location:$img"); exit; } } ############## if ( $_GET[rand] ) { rand_img( $_GET[rand], $images ); exit; } ########################### ?> <?=$title; ?>

"; for ( $x = 1; $x<$pages+1; $x++) { echo "$x"; if ( $x<$pages ) { echo " | "; } } echo "


"; ########################### # Paginate $start = $page*$per_page-$per_page; # Display contents of page $contents = array_slice( $images, $start, $per_page ); $x = 1; foreach($contents as $temp ) { echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"; #### Get size of thumb for faster page loading $thumb = new imagick( "$temp" ); $thumb->thumbnailImage( 100, 100, TRUE); $w = $thumb->getimagewidth(); $h = $thumb->getimageheight(); # write thumb # $thumb->writeimage("thumb_$temp"); #### Display thumb and link echo ""; echo ""; #### Get stats $filesize = filesize($temp); list( $width, $height, $type ) = getimagesize("$temp"); #### show stats echo "($x) $temp
"; echo "$width X $height
"; $x++; echo "$filesize bytes"; echo "
"; } ?>


^