<html><head><title>agal thumbnail maker</title></head>
<body>THIS SCRIPT IS USING THE GD2 LIB !!<br>
generating thumbnails, this can take some time. Please wait :o)
<br><strong>If the output looks VERY crappy, you can use make_thumbnails.pl (works only on unix ) for better results.</strong>
<br>Check out your <a href="phpgallery.php"><strong>Gallery</strong></a>.

<br>
<?php	

umask(000);
if(  !is_dir("thumb")){mkdir('thumb',0777);}

$dir = opendir('./');
    while($file = readdir($dir)) {
	if (substr($file, -3) == 'jpg' || (substr($file, -3) == 'JPG' ))
    		$all_jpegs[] = $file;
        }
$nr_of_pics = (sizeof ($all_jpegs));

foreach( $all_jpegs as $file){
$jpeg_size = GetImageSize ($file);
$x = $jpeg_size[0];
$y = $jpeg_size[1];
if ( $x / $y >= 800 / 600 ){
    $y = 160 / ($x/$y);
    $x = 160;
    }
    else {
	$x = 120 * ($x/$y);
	$y = 120; 
	}



//header("Content-type: image/Jpeg");
$dst_img=imagecreatetruecolor($x,$y);
$src_img=ImageCreateFromJpeg($file);
ImageCopyResized($dst_img,$src_img,0,0,0,0,$x,$y,ImageSX($src_img),ImageSY($src_img));
Imagejpeg($dst_img,"./thumb/$file");

}


?>


</body>
</html>
