0
我试图通过在其周围添加透明度来调整图像画布的大小(如在Photoshop中)。不知何故,添加图像的一部分始终是黑色的。使用CodeIgniter图像库调整图像画布的大小 - 如何保留透明度
if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor'))
{
$create = 'imagecreatetruecolor';
$copy = 'imagecopyresampled';
}
else
{
$create = 'imagecreate';
$copy = 'imagecopyresized';
}
$dst_img = $create($this->width, $this->height);
if ($this->image_type == 3) // png we can actually preserve transparency
{
//teorethicaly image should be transparent?
$trans_colour = imagecolorallocatealpha($dst_img, 0, 0 ,0, 127);
imagefill($dst_img, 0, 0, $trans_colour);
imagealphablending($dst_img, FALSE);
imagesavealpha($dst_img, TRUE);
}
$copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);
如果我删除$copy
并只保存新的图像,它是透明的,但如果我合并两个图像的背景始终是黑色的:
我怎么能在那种情况下透明背景?
在此先感谢!
它的'&&'不'AND'在if条件下 – Saty
我相信这部分不影响任何东西 - 它进入条件内部,而这部分是来自CodeIgniter库的未触动代码 –