<?php
class thumbnailcreater
{
function creat($thname,$thumbnailwidth,$thumbnailheight,$image,$type)
{
//echo $type;
//if($type == 'image/gif')
if($type == '.gif')
{
$mainimage=imagecreatefromgif($image);
}
else
{
$mainimage=imagecreatefromjpeg($image);
}
//get the width and height of main image	
$mainwidth = imagesx($mainimage);
$mainheight = imagesy($mainimage);
$mythumbnail = imagecreatetruecolor($thumbnailwidth,$thumbnailheight);
imagecopyresampled($mythumbnail,$mainimage,0,0,0,0,$thumbnailwidth,$thumbnailheight,$mainwidth,$mainheight);
if($type == '.gif')
{
ImageGIF($mythumbnail,$thname,95);
}
else
{
ImageJPEG($mythumbnail,$thname,95);
}
imagedestroy($mythumbnail);
imagedestroy($mainimage);
}
}
?>