我需要将PNG图片的背景颜色(https://chart.googleapis.com/chart?cht=lxy&chd=e:AACIERGZIiKqMzO7RETMVVXdZmbud3f.iIkQmZohqqsyu7xDzM1U3d5l7u92,hhiIivfFmZZmcCY.YYZmTgdQjWd3kk6g880asfu7r4sf4E22tGtGsfzzmZj9&chds=0.0,1.0&chs=105x75&chma=1,0,1,1&chco=42b6c9ff&chls=2.5,1.0,0.0&chxl=0:%7C%7C1:%7C%7C2:%7C)更改为透明。我用下面的代码,在我看来,正确的:PHP - 将背景颜色更改为透明
$picture = imagecreatefrompng("https://chart.googleapis.com/chart?cht=lxy&chd=e:AACIERGZIiKqMzO7RETMVVXdZmbud3f.iIkQmZohqqsyu7xDzM1U3d5l7u92,hhiIivfFmZZmcCY.YYZmTgdQjWd3kk6g880asfu7r4sf4E22tGtGsfzzmZj9&chds=0.0,1.0&chs=105x75&chma=1,0,1,1&chco=42b6c9ff&chls=2.5,1.0,0.0&chxl=0:%7C%7C1:%7C%7C2:%7C");
$img_w = imagesx($picture);
$img_h = imagesy($picture);
imagealphablending($picture, false);
imagesavealpha($picture, true);
$rgb = imagecolorexact ($picture, 255,255,255);//imagecolorat($picture, 50, 50);
imagecolortransparent($picture, $rgb);
imagepng($picture, '../images/chart2.png');
imagedestroy($picture);
我用imagecolorat
太检测准确的色彩,但结果是一样的 - 它不工作(背景为白色(不透明))!我的错误是什么?
可能的重复:PHP: How to make a green area (background) in an image transparent? 和 imagecolortransparent in PHP not working
你为什么创建'$ image'和'$ img'? – Nolesh