我试图通过在其周围添加透明度来调整图像画布的大小(如在Photoshop中)。不知何故,部分图像总是黑色。
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
并仅保存新图片,则它是透明的,但如果我合并两张图片,则背景始终为黑色:
在这种情况下我如何拥有透明背景?
提前致谢!
答案 0 :(得分:1)