title: Replace transparent color in PHP
body: <p>I have set of images. In this images exist green alpha color. I need replace that transparent color to another color (i want replace to white alpha color).</p>
  
  <p>Its my code:</p>
  
  <pre><code>$img = imagecreatefrompng($path . $file); 
  $white_color_transparent = imagecolorallocatealpha($img, 255, 255, 255, 127);
  for ($y = 0; $y &lt; imagesy($img); $y++) {
      for ($x = 0; $x &lt; imagesx($img); $x++) {
          $rgb = imagecolorat($img, $x, $y);
          $pixel_color = imagecolorsforindex($img, $rgb);
          if ($pixel_color['alpha'] != 0 &amp;&amp; $pixel_color['alpha'] != 127){
              imagesetpixel($img, $x, $y, $white_color_transparent);
          }
      }
  }
  
  imagealphablending($img, false);
  imagesavealpha($img, true);            
  imagepng($img, $path .  $file);
  </code></pre>
  
  <p>And my result color its the same than id source image, when i add before </p>
  
  <pre><code>imagesetpixel($img, $x, $y, $white_color_transparent);
  </code></pre>
  
  <p>that line:</p>
  
  <pre><code>imagesetpixel($img, $x, $y, $white_color);
  </code></pre>
  
  <p>i get only white color without transparency.</p>