[eluser]sidhartha[/eluser]
replace the line
Code:
$copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);
with the following at line number 512 or around it in Image_lib.php. it maintains transparency for both gif and png images. note the
imagefilledrectangle() replacing
imagefill(). with imagefill() the transparent part becomes black. but imagefilledrectangle() maintains transparency.
Code:
$proprts = $this->get_image_properties($this->full_src_path, TRUE);
$cr_img_type = $proprts['image_type'];
//$cr_width = $proprts['width'];
//$cr_height = $proprts['height'];
if ($cr_img_type == 3)//for png
{
imagealphablending( $dst_img, false );
imagesavealpha( $dst_img, true );
$transparent_index = imagecolorallocatealpha($dst_img,0,255,0,127);
// imagefill($dst_img, 0, 0, $transparent_index);
imagefilledrectangle($dst_img, 0, 0, $this->width, $this->height, $transparent_index);
$copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);
}
else if($cr_img_type == 1)//for gif
{
$transparent_index = imagecolortransparent($src_img);
if ($transparent_index >= 0) {
imagepalettecopy($src_img, $dst_img);
// imagefill($dst_img, 0, 0, $transparent_index);
imagefilledrectangle($dst_img, 0, 0, $this->width, $this->height, $transparent_index);
imagecolortransparent($dst_img, $transparent_index);
imagetruecolortopalette($dst_img, true, 256);
}
$copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);
}
else//for other
{
$copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);
}