title: PHP imagecopymerge source image's background change transparent to black
body: <p>I need to merge two pictures,
  my code is like this:</p>
  
  <pre><code>$image = imagecreatefromjpeg("images/big.jpg"); 
  $image1 = imagecreatefrompng("small_image/8.png");
  $size = getimagesize("small_image/8.png");
  
  
  imagecopymerge($image, $image1, 400, 30, 0, 0, $size[0], $size[1], 100);
  header('Content-Type: image/gif');
  imagegif($image);
  imagedestroy($image1);
  </code></pre>
  
  <p><br />
  the frist picture is :</p>
  
  <p><img src="https://i.stack.imgur.com/YQerz.jpg" alt="enter image description here"></p>
  
  <p>second is :
  <img src="https://i.stack.imgur.com/W6haK.png" alt="enter image description here"></p>
  
  <p>final result not transparent </p>
  
  <p><img src="https://i.stack.imgur.com/mKE5Y.gif" alt="enter image description here"></p>
  
  <p>Please help!!!Thanks!</p>
  
  <p>new version of code:</p>
  
  <pre><code>$image = imagecreatefromjpeg("images/big.jpg"); 
  $image1 = imagecreatefrompng("small_image/8.png");
  $size = getimagesize("small_image/8.png");
  $background = imagecolorallocate($image, 0, 0, 0);
  imagecolortransparent($image, $background);
  imagealphablending($image1, false);
  imagesavealpha($image1, true);
  
  
  imagecopymerge($image, $image1, 400, 30, 0, 0, $size[0], $size[1], 100);
  
  header('Content-Type: image/gif');
  
  
  imagegif($image);
  imagedestroy($image1);
  </code></pre>
  
  <p>and the result is :
      <img src="https://i.stack.imgur.com/khrHi.gif" alt="enter image description here"></p>