Hi -- I am using the following code to generate the thumbnails for my uploaded images --
function createThumbnail($filesavepath, $basefilename, $ext, $thumbwidth, $thumbdir) {
if($ext == "jpg" || $ext == "JPG" || $ext == "Jpg")
{
$im = imagecreatefromjpeg($filesavepath);
} else if($ext == "gif" || $ext == "GIF" || $ext == "Gif") {
$im = imagecreatefromgif($filesavepath);
} else if($ext == "png" || $ext == "PNG" || $ext == "Png") {
$im = imagecreatefrompng($filesavepath);
}
$ox = imagesx($im);
$oy = imagesy($im);
$nx = $thumbwidth;
$ny = floor($oy * ($thumbwidth / $ox));
$nm = imagecreatetruecolor($nx, $ny);
imagecopyresized($nm, $im, 0,0,0,0,$nx,$ny,$ox,$oy);
if(!file_exists($thumbdir)) {
if(!mkdir($thumbdir)) {
die("There was a problem. Please try again!");
}
}
imagejpeg($nm, $thumbdir . $basefilename, 100);
$thumburl = $thumbdir . $basefilename;
if(file_exists($thumburl)) { return 1; } else { return 0; }
}
To show you the quality of thumbnails being produced --
Original: http://dotep.com/ful/media/1226195461358-9bd12.jpg
Thumbnail: http://dotep.com/ful/media/thumbnails/1226195461358-9bd12.jpg
Now, any ideas how to improve the quality of thumbnails I can generate of the images?