Новичок
Покинул форум
Сообщений всего: 2
Дата рег-ции: Окт. 2007
Помог: 0 раз(а)
|
Помогите разобраться почему при выполнении следующей функции, PNG вместо прозрачного фона сохраняются с синим фоном ?? Хотя GIF при этом прекрасно сохраняется с прозрачностью...
CODE ( text):
скопировать код в буфер обмена
function imageresize2($outfile,$infile,$neww,$newh,$quality, $ftype) { $ftype=strtoupper($ftype); switch ($ftype) { case "JPEG" : $im=imagecreatefromjpeg($infile); break; case "JPE" : $im=imagecreatefromjpeg($infile); break; case "JPG" : $im=imagecreatefromjpeg($infile); break; case "PNG" : $im=imagecreatefrompng($infile); break; case "GIF" : $im=imagecreatefromgif($infile); } $imagesize = getimagesize($infile); $width = $imagesize[0]; $height = $imagesize[1]; $x=1.0; if ($width>$neww) $x=$neww/$width; if (($height*$x)>$newh) $x=$newh/$height; $neww=round($width*$x); $newh=round($height*$x); $im1=imagecreatetruecolor($neww, $newh); $bgcolor = imagecolortransparent($im); imagefill($im1, 0,0, $bgcolor); imagecolortransparent($im1, $bgcolor); imagecopyresampled($im1, $im, 0, 0, 0, 0, $neww, $newh, $width, $height); switch ($ftype) { case "JPEG" : imagejpeg($im1,$outfile,$quality); break; case "JPE" : imagejpeg($im1,$outfile,$quality); break; case "JPG" : imagejpeg($im1,$outfile,$quality); break; case "PNG" : imagepng($im1,$outfile); break; case "GIF" : imagegif($im1,$outfile); } imagedestroy($im); imagedestroy($im1); }
|