title: PHP - change background color to transparent
body: <p>I need to change background color of PNG picture (<a href="https://chart.googleapis.com/chart?cht=lxy&amp;chd=e:AACIERGZIiKqMzO7RETMVVXdZmbud3f.iIkQmZohqqsyu7xDzM1U3d5l7u92,hhiIivfFmZZmcCY.YYZmTgdQjWd3kk6g880asfu7r4sf4E22tGtGsfzzmZj9&amp;chds=0.0,1.0&amp;chs=105x75&amp;chma=1,0,1,1&amp;chco=42b6c9ff&amp;chls=2.5,1.0,0.0&amp;chxl=0:%7C%7C1:%7C%7C2:%7C" rel="nofollow noreferrer">https://chart.googleapis.com/chart?cht=lxy&amp;chd=e:AACIERGZIiKqMzO7RETMVVXdZmbud3f.iIkQmZohqqsyu7xDzM1U3d5l7u92,hhiIivfFmZZmcCY.YYZmTgdQjWd3kk6g880asfu7r4sf4E22tGtGsfzzmZj9&amp;chds=0.0,1.0&amp;chs=105x75&amp;chma=1,0,1,1&amp;chco=42b6c9ff&amp;chls=2.5,1.0,0.0&amp;chxl=0:%7C%7C1:%7C%7C2:%7C</a>) to transparent. I use the following code which seems to me right:</p>
  
  <pre><code>$picture = imagecreatefrompng("https://chart.googleapis.com/chart?cht=lxy&amp;chd=e:AACIERGZIiKqMzO7RETMVVXdZmbud3f.iIkQmZohqqsyu7xDzM1U3d5l7u92,hhiIivfFmZZmcCY.YYZmTgdQjWd3kk6g880asfu7r4sf4E22tGtGsfzzmZj9&amp;chds=0.0,1.0&amp;chs=105x75&amp;chma=1,0,1,1&amp;chco=42b6c9ff&amp;chls=2.5,1.0,0.0&amp;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);
  </code></pre>
  
  <p>I used <code>imagecolorat</code> too to detect accurate color, but the result is the same - it doesn't work(the background is white(not transparent))! What is my mistake?</p>
  
  <p>Possible duplicates: <a href="https://stackoverflow.com/questions/9852267/php-how-to-make-a-green-area-background-in-an-image-transparent">PHP: How to make a green area (background) in an image transparent?</a>
  and 
  <a href="https://stackoverflow.com/questions/15722301/imagecolortransparent-in-php-not-working">imagecolortransparent in PHP not working</a></p>