Location: PHPKode > scripts > PHP Image Gallery > php-image-gallery-http-phpimagegallery-com/phpgallery/include_imaging_gd.php
<?php

// php.ini add line : extension="ext/php_gd2.dll"

function PhpGallery_Impl_LoadImage($imagefile)
{
	$ext=pathinfo($imagefile,PATHINFO_EXTENSION);
	switch(strtolower($ext))
	{
		case "png":
			return imagecreatefrompng($imagefile);
		case "gif":
			return imagecreatefromgif($imagefile);
		case "jpg":
		case "jpeg":
		default:
			return imagecreatefromjpeg($imagefile);
	}
}

function PhpGallery_GetPhotoDimensions($imagefile)
{
	$img=PhpGallery_Impl_LoadImage($imagefile);
	$size=array();
	$size["Width"]=imagesx($img);
	$size["Height"]=imagesy($img);
	imagedestroy($img);
	return $size;
}
function PhpGallery_GenerateThumbnail($imagefile,$thumbpath,$width,$height)
{
	$img=PhpGallery_Impl_LoadImage($imagefile);
	$thumb=imagecreatetruecolor($width,$height);
	imagecopyresized($thumb,$img,0,0,0,0,$width,$height,imagesx($img),imagesy($img));
	imagejpeg($thumb,$thumbpath);
	imagedestroy($img);
	imagedestroy($thumb);
}

?>
Return current item: PHP Image Gallery