PHP-从白色制作透明背景

PHP-从白色制作透明背景,php,image,gd,Php,Image,Gd,我有一个函数,它可以将白色背景移到白色,但当我尝试使用imagecopy将新图像复制到新图像上时,图像仍然具有白色背景。如果有人能告诉我哪里出了问题,我会非常高兴,因为我现在很沮丧,因为这应该是有效的。而且,当我打开在paint中创建的图像时,它仍然有一个白色背景。 输出的图像是透明的,但在复制时有白色背景。 提前谢谢 这是密码 public function transparent_background($filename, $color, $image) { $img = imagecr

我有一个函数,它可以将白色背景移到白色,但当我尝试使用imagecopy将新图像复制到新图像上时,图像仍然具有白色背景。如果有人能告诉我哪里出了问题,我会非常高兴,因为我现在很沮丧,因为这应该是有效的。而且,当我打开在paint中创建的图像时,它仍然有一个白色背景。 输出的图像是透明的,但在复制时有白色背景。 提前谢谢 这是密码

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;
}

这是一个打字错误

这是错误的,请参见第三个参数

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


那是我试图在这里输入的。问题仍然存在,副本上有白色背景\
public function transparent_background($filename, $color,$image)