hello i am doing png image cropping using this function. every thing is working fine. but whenever i was uploaded .png then changing the image background color into black. here is the code
$bgimage_attribs = getimagesize($bgim_file_name);
if($filetype3=='image/gif')
{
$bgim_old = imagecreatefromgif($bgim_file_name);
}
else if(($filetype3=='image/pjpeg') || ($filetype3=='image/jpeg'))
{
$bgim_old = imagecreatefromjpeg($bgim_file_name);
}
else if(($filetype3=='image/png') || ($filetype3=='image/x-png'))
{
$bgim_old = imagecreatefrompng($bgim_file_name);
}
$bgth_max_width =265; //for Album image
$bgth_max_height =150;
$bgratio = ($bgwidth > $bgheight) ? $bgth_max_width/$bgimage_attribs[0] : $bgth_max_height/$bgimage_attribs[1];
$bgth_width =265;//$image_attribs[0] * $ratio;
$bgth_height =150;//$image_attribs[1] * $ratio;
$bgim_new = imagecreatetruecolor($bgth_width,$bgth_height);
imageantialias($bgim_new,true);
$bgth_file_name = "partners_logs/250x150/$Attachments3";
imagecopyresampled($bgim_new,$bgim_old,0,0,0,0,$bgth_width,$bgth_height, $bgimage_attribs[0], $bgimage_attribs[1]);
if($filetype3=='image/gif')
{
imagegif($bgim_new,$bgth_file_name,100);
//$bgim_old = imagegif($bgim_file_name);
}
else if(($filetype3=='image/pjpeg') || ($filetype3=='image/jpeg'))
{
imagejpeg($bgim_new,$bgth_file_name,100);
}
else if(($filetype3=='image/png') || ($filetype3=='image/x-png'))
{
imagepng($bgim_new,$bgth_file_name,9);
}
my problem is in 36,37 lines. image quality. getting balck color in background of the image