*/
function resizeimage($imagepath, $thumb, $width = 200, $height = 200)
{
list($imagewidth, $imageheight) = getimagesize($imagepath);
$imagepath = imagecreatefromjpeg($imagepath);
if ($width && ($imagewidth < $imageheight))
{
$width = ($height / $imageheight) * $imagewidth;
}
else
{
$height = ($width / $imagewidth) * $imageheight;
}
$image = imagecreatetruecolor($width, $height);
imagecopyresampled($image, $imagepath, 0, 0, 0, 0, $width, $height, $imagewidth, $imageheight);
imagepng($image, $thumb);
imagedestroy($image);
}
resizeimage('test.jpg', 'test_thumb.jpg');
?>