<?<br />if( ! isset( $filename ) ){<br />define( "SIZE" , 120 ) ;<br />define( "COLNUM" , 5 ) ;<br />$dir = ($dir)?$dir:"." ;<br />?><br /><html><br /><head><br /><title>Our Pictures <?= $dir ?></title><br /><style type="text/css"><br /><!--<br />table{<br />width:100%;<br />}<br />td{<br />text-align:center;<br />}<br />img{<br />border:none;<br />}<br />--><br /></style><br /></head><br /><body><br /><table><br /><?<br />$dd = opendir($dir) ;<br /><br />for( $i = 0 ; $filename = readdir($dd) ; ){<br />if( is_file("$dir/$filename") ){<br />if( $imgSize = getImageSize("$dir/$filename") ){<br /><br />$w0 = $imgSize[0] ;<br />$h0 = $imgSize[1] ;<br /><br />$imgType = $imgSize[2] ;<br /><br />$ratio = $w0 / $h0 ;<br /><br />if( $ratio > 1 ){<br />$w1 = SIZE ;<br />$h1 = ( SIZE * $h0 ) / $w0 ;<br />}<br />else{<br />$w1 = ( SIZE * $w0 ) / $h0 ;<br />$h1 = SIZE ;<br />}<br /><br />$params = sprintf( "filename=$dir/$filename&w0=$w0&h0=$h0&imgType=$imgType&h1=%d&w1=%d" , $h1 , $w1 ) ;<br /><br />if( ! ( $i % COLNUM ) ){<br />echo "\n<tr>\n" ;<br />}<br />?><br /><td><br /><a href="<?= "$dir/$filename" ?>"><br /><img src="<?= $filename ?>?<?= $params ?>" style="width:<?= $w1 ?>;height:<?= $h1 ?>;"></a><br><br /><?= "$filename : $w0 x $h0" ?><br /><?<br />$i++ ;<br />}<br />}<br />}<br />?><br /></table><br /></body><br /></html><br /><?<br />closedir($dd) ;<br />}<br />else{<br />switch($imgType){<br />case 1:<br />$imgType = "gif" ;<br />break;<br /><br />case 2:<br />$imgType = "JPEG" ;<br />break;<br /><br />case 3:<br />$imgType = "png" ;<br />break;<br /><br />default:<br />break;<br />}<br />header("Content-type: image/$imgType") ;<br /><br />$tImg = imageCreate( $w1 , $h1 ) ;<br /><br />$imgOpenFunc = "imageCreateFrom".$imgType ;<br />$imgSendFunc = "image".$imgType ;<br /><br />$img = $imgOpenFunc("$filename") ;<br /><br />imageCopyResized( $tImg , $img , 0 , 0 , 0 , 0 , $w1 , $h1 , $w0 , $h0 ) ;<br /><br />imageDestroy($img) ;<br /><br />$imgSendFunc($tImg) ;<br />}<br />?><br />