Page 1 of 1

[SOLVED]problem with thumbnail creation

Posted: Sun Mar 06, 2005 12:08 pm
by dull1554
ok i user this function to create thumbnails

Code: Select all

function makethumb($sourcefile, $destfile, $imgcomp = 0)
{
$g_srcfile=$sourcefile;
$g_dstfile=$destfile;
if(file_exists($g_srcfile))
{
$g_is=getimagesize($g_srcfile);
$g_fw=$g_isї0]/4;
$g_fh=$g_isї1]/4;
if(($g_isї0]-$g_fw)>=($g_isї1]-$g_fh))
{
$g_iw=$g_fw;
$g_ih=($g_fw/$g_isї0])*$g_isї1];
}
else
{
$g_ih=$g_fh;
$g_iw=($g_ih/$g_isї1])*$g_isї0];
}
$img_src=imagecreatefromjpeg($g_srcfile);
$img_dst=imagecreate($g_iw,$g_ih);
imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih, $g_isї0], $g_isї1]);
imagejpeg($img_dst, $g_dstfile);
imagedestroy($img_dst);
return true;
}
else
return false;
}
well it kinda works, it makes the thumbnail at the correct size, the only problem i face is that it screws up the images color, it doesent pixelate it just makes it look like crap....

im not very expierenced with GDlib and i could not find anyother people that have had a similar problem so if ne one can help thanks a bunch
~dull1554

Posted: Sun Mar 06, 2005 12:28 pm
by feyd
imagecreatetruecolor() instead of imagecreate()

Posted: Sun Mar 06, 2005 12:59 pm
by dull1554
thanks, works perfectly :)