title: Merge a png ontop of a jpg and retain transparency with php
body: <p>I have a PNG and I'm trying to merge it on top of a JPG. With the following code</p>
  
  <pre><code>$dest = imagecreatefromjpeg("example.jpg");
  $src = imagecreatefrompng("example.png");
  
  imagealphablending($dest, false);
  imagesavealpha($dest, true);
  
  imagealphablending($src, true);
  
  imagecopymerge($dest, $src, $src2x, $src2y, 0, 0, $src2w, $src2h, 100);
  
  header('Content-Type: image/png');
  imagepng($dest, "user/".$imei."/".$picCount."_m");
  
  imagedestroy($dest);
  imagedestroy($src);
  </code></pre>
  
  <p>Results in the following </p>
  
  <p><img src="https://i.stack.imgur.com/sLXSn.jpg" alt="enter image description here"></p>
  
  <p>I also tried a <a href="https://stackoverflow.com/a/6466165/773263">suggestion from a similar question</a> which said to use 'imagecopyresampled' isntead of 'imagecopymerge' but when I did that the santa hat didn't show up at all.</p>
  
  <p>What do I need to change to make the santa hat keep it's transparency when merged?</p>