I found this script online that creates a thumbnail out of a image but the thumbnail image is created with poor quality how can I improve the quality of the image.
And is there a better way to create thumbnails if so can you point me to a tutorial on how to create thumbnails using PHP.
Here is the code below.
<?php
function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth)
{
$srcImg = imagecreatefromjpeg("$imageDirectory/$imageName");
$origWidth = imagesx($srcImg);
$origHeight = imagesy($srcImg);
$ratio = $origWidth / $thumbWidth;
$thumbHeight = $origHeight / $ratio;
$thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresized($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $origWidth, $origHeight);
imagejpeg($thumbImg, "$thumbDirectory/$imageName");
}
createThumbnail("images", "pic.jpg", "images/thumbs/", 180);
?>