title: Is it possible to create an PNG with full alpha channel by using: imagecolortransparent()
body: <p>I'm looking for a way to create a transparent area in an image by using its aplha channel.</p>
  
  <p><em>I just found that way:</em> </p>
  
  <p>Define a color and set it to transparent.</p>
  
  <pre><code>imagealphablending($img, false);   // has to be false for imagecolortransparent
  imagesavealpha($img, false);       // false = single color transparency
  
  $mask_color = imagecolorallocatealpha($img, 0, 255, 0, 127);
  imagecolortransparent( $img, $mask_color );
  </code></pre>
  
  <p>But the result is a single color transparency. If i try to merge it with an image with alpha channel, the mask color gets visible again. </p>
  
  <p>This happens at the moment i enable imagesavealpha() again, needed for that merge prozess.</p>
  
  <p>By the way: I create the <em>$img</em> by merging a source image with an mask image.</p>
  
  <pre><code>$new_img = imagecreatetruecolor( 150, 100 );
  $new_white = imagecolorallocatealpha( $new_img, 255, 255, 255, 0 );
  imagefill( $new_img, 0, 0, $new_white );
  
  imagealphablending($new_img, false);   // has to be false for full alpha
  imagesavealpha($new_img, true);       // true = full alpha channel
  
  imagecopyresampled( $new_img, $img       ,0, 0, 0, 0, 150, 100, 150, 100);
  imagecopyresampled( $new_img, $alpha_img ,0, 0, 0, 0, 150, 100, 150, 100);
  
  // save preview
  imagepng( $new_img, $image_path . $preview_dir_name . $new_file_name );
  </code></pre>
  
  <p>The transparent areas from <em>$img</em> are now visible again.</p>
  
  <p>So, is there a way to make an specific colored area transparent by using the full alpha channel?</p>