Location: PHPKode > scripts > EazyGallery > eazygallery/thumbz.php
<?php
	#########################################################################################
	#       Eazy Gallery 0.9.0 by Linkdesign.
	#       e-mail: hide@address.com
	#       GD 2 or higher required!
	#########################################################################################

	$dir = $_GET['dir'];				// Get a folder name
	$pict = $_GET['pict'];				// Get a picture name
	$size = GetImageSize($dir . $pict);	// Get an array with imagesize
	$src_width  = $size[0];
	$src_height = $size[1];

	// Settings for thumbsize based on original size / x
/*	if($src_width < 150)
	{
		$dst_width  = $src_width;
		$dst_height = $src_height;
	}
	else if($src_width > 150 && $src_width < 650)
	{
		$dst_width  = $src_width / 6;
		$dst_height = $src_height / 6;
	}
	else if($src_width > 1200)
	{
		$dst_width  = $src_width / 15;
		$dst_height = $src_height / 15;
	}
	else
	{
		$dst_width  = $src_width / 8;
		$dst_height = $src_height / 8;
	} */
	
	$dst_width  = 103;
	$dst_height = 77;
	
	$sFileType = strstr($pict, ".");	// Extrakting extension
	$arrJPEG = array(".jpeg", ".jpg", ".JPG", ".JPEG");	// Setting up arrays with extensions
	$arrPNG = array(".PNG", ".png");
	$arrGIF = array(".GIF", ".gif");

	// If folder does not exist, create it and give it 755 mode
	if(!file_exists($dir.'thumbz'))
	{
		mkdir($dir.'thumbz',0755);
	}
	
	// Making thumbnail

	if (in_array($sFileType, $arrJPEG))	// If it is a JPEG file
	{
		header ("Content-type: image/jpeg");
		$src = imagecreatefromjpeg($dir.$pict);	// Reading original file
		$dst = imagecreatetruecolor($dst_width,$dst_height);	// Create empty image
		imagecopyresampled($dst,$src,0,0,0,0,$dst_width,$dst_height,$src_width,$src_height);	//Copy resized original image to emptyone
		imagejpeg($dst);             								// send to browser
		imagejpeg($dst, $dir."thumbz/tb_".$pict, 80);     	//save thumbnail to filesystem
		chmod($dir."thumbz/tb_".$pict, 0755);	// Change mode
		imagedestroy($dst);				// Deletin images from memmory
		imagedestroy($src);
	}

	// Same as above only for PNG's

	else if(in_array($sFileType, $arrPNG))
	{
		header ("Content-type: image/png");
		$src = imagecreatefrompng($dir.$pict);
		$dst = imagecreatetruecolor($dst_width,$dst_height);
		imagecopyresampled($dst,$src,0,0,0,0,$dst_width,$dst_height,$src_width,$src_height);
		imagepng($dst);
		imagepng($dst, $dir."thumbz/tb_".$pict);
		chmod($dir."thumbz/tb_".$pict, 0755);
		imagedestroy($dst);
		imagedestroy($src);
	}
	
	// Same as above only for PNG's
	
	else if(in_array($sFileType, $arrGIF))
	{
		header ("Content-type: image/gif");
		$src = imagecreatefromgif($dir.$pict);
		$dst = imagecreatetruecolor($dst_width,$dst_height);
		imagecopyresampled($dst,$src,0,0,0,0,$dst_width,$dst_height,$src_width,$src_height);
		imagegif($dst);
		imagegif($dst, $dir."thumbz/tb_".$pict);
		chmod($dir."thumbz/tb_".$pict, 0755);
		imagedestroy($dst);
		imagedestroy($src);
	}
?>
Return current item: EazyGallery