title: PHP GD turn background into transparent or alpha
body: <p><img src="https://i.stack.imgur.com/L6IJb.jpg" alt="enter image description here"></p>
  
  <p>I have an jpeg image, I want to use php GD to create 2 boxs.</p>
  
  <ol>
  <li><p>left box will remove background and set transparent</p></li>
  <li><p>Right box will set rgba - alpha 80%;</p></li>
  </ol>
  
  <p>and save it in png transparance</p>
  
  <p>I have try imagesetpixel, but its not transparent,</p>
  
  <p>I also try imagecolortransparent</p>
  
  <pre><code>$transparentcolour = imagecolorallocate($im, 40,220,1);
  imagecolortransparent($image, $transparentcolour);
  </code></pre>
  
  <p>but this will turn everything into transparent in this color.</p>
  
  <p>anyone know how to achieve this?</p>