How to create Create Thumbnail Image in PHP

How to create Create Thumbnail Image in PHP


function createThumbnail($sourceImage, $thumbImage, $thumbWidth)
{
$srcImg = imagecreatefromjpeg($sourceImage);
$origWidth = imagesx($srcImg);
$origHeight = imagesy($srcImg);

$ratio = $origWidth / $thumbWidth;
$thumbHeight = floor($origHeight / $ratio);
$thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresized($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $origWidth, $origHeight);
imagejpeg($thumbImg, $thumbImage);

}