Page 1 of 1

how to increase thumbnail quality

Posted: Sat Dec 13, 2008 10:56 pm
by lukelee
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


here is my code, the quality of the thumbnail is really bad. almost white and black with blur. anyone know how to make my code better?

Code: Select all

 
function makethumb($srcFile,$dstFile,$dstW,$dstH) {
$data = GetImageSize($srcFile,&$info);
switch ($data[2]) {
case 1:
$im = @ImageCreateFromGIF($srcFile);
break;
case 2:
$im = @imagecreatefromjpeg($srcFile);
break;
case 3:
$im = @ImageCreateFromPNG($srcFile);
break;
}
$srcW=ImageSX($im);
$srcH=ImageSY($im);
$ni=ImageCreate($dstW,$dstH);
 
Imagecopyresampled($ni,$im,0,0,0,0,$dstW,$dstH,$srcW,$srcH);
ImageJpeg($ni,$dstFile, 80);

~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: how to increase thumbnail quality

Posted: Sun Dec 14, 2008 12:28 am
by SteveC
Try using imagecreatetruecolor() instead. :)

Re: how to increase thumbnail quality

Posted: Mon Dec 15, 2008 5:06 pm
by pickle
Increasing the 3rd argument to imagejpeg to 100 from 80 will also increase the quality of the final image file, though probably not perceivably so.

Re: how to increase thumbnail quality

Posted: Mon Dec 15, 2008 5:21 pm
by FunkyDude
I'm pretty sure that the image quality is negligible with GD library, I'm not entirely sure but I think using ImageMajick to create jpegs can possibly make higher quality images.