note 42520 added to function.getimagesize

From: Date: Wed, 19 May 2004 18:34:03 +0000
Subject: note 42520 added to function.getimagesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-69843@lists.php.net to get a copy of this message
Hi, this is my first post to php.net... I give you a little thumbnail images resize. It list the directory content images : <? // Some configuration variables ! $maxWidth = 100; $maxHeight = 100; $maxCols = 8; $webDir = "https://www.davannsolutions.com/images/"; $localDir = $_SERVER['DOCUMENT_ROOT']."/images/"; $AutorisedImageType = array ("jpg", "jpeg", "gif", "png"); ?> <center> <table border='1' cellspacing='10' cellpadding='0' style="border-collapse:collapse; border-style: dotted"> <tr> <? // Open localDir $dh = opendir($localDir); while (false !== ($filename = readdir($dh))) { $filesArray[] = $filename; } // Display and resize foreach ($filesArray as $images) { $ext = substr($images, strpos($images, ".")+1, strlen($images)); if( in_array($ext, $AutorisedImageType) ) { list($width, $height, $type, $attr) = @getimagesize( $localDir.$images ); if($width <= $maxWidth && $height <= $maxHeight) { if($i == $maxCols) { echo "</tr><tr>"; $i = 0; } echo "<td align='center' valign='middle' width='$maxWidth' height='$maxHeight'><img src='".$webDir.$images."'></td>"; $i++; } else { if($width > $maxWidth && $height <= $maxHeight) { if($i == $maxCols) { echo "</tr><tr>"; $i = 0; } echo "<td align='center' valign='middle' width='$maxWidth' height='$maxHeight'><img src='".$webDir.$images."' width='$maxWidth'></td>"; $i++; } if($width <= $maxWidth && $height > $maxHeight) { if($i == $maxCols) { echo "</tr><tr>"; $i = 0; } echo "<td align='center' valign='middle' width='$maxWidth' height='$maxHeight'><img src='".$webDir.$images."' height='$maxHeight'></td>"; $i++; } } } } ?> </tr> </table> </center> ---- Manual Page -- http://www.php.net/manual/en/function.getimagesize.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42520 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42520&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42520&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69843) next »