2013-12-20 128 views
0

我有一个功能,它可以将白色背景移除为白色,但是当我尝试将新图像复制到新图像时,图像仍具有白色背景imagecopy。如果有人能告诉我哪里出错了,我会很开心,因为现在应该是有效的。而且当我打开在油漆中创建的图像时,它仍然具有白色背景。 输出的图像是透明的,但副本上有白色背景。 在此先感谢 这里是代码PHP - 从白色制作透明背景

public function transparent_background($filename, $color, $image) 
{ 
    $img = imagecreatefromjpeg($image); 
    $colors = explode(',', $color); 
    $remove = imagecolorallocate($img, $colors[0], $colors[1], $colors[2]); 
    imagecolortransparent($img, $remove); 
    imagepng($img, $filename,0); 
    return $img; 
} 

回答

0

这是打错了,

这是错误看到第三个参数

public function transparent_background($filename, $color,$imgage) 

尝试

public function transparent_background($filename, $color,$image) 
+0

那是我试图在这里输入。有问题仍然存在,副本上有白色背景\ – emuigai