title: Merging two images in PHP
body: <p>I'm building a web application where you can design something, at the end of the process it outputs two images. One is a gif and the other is a jpeg. I am looking to take both images and merge them into one image. However after trying a few techniques none seem to work. </p>
  
  <p>My script is as follows:</p>
  
  <pre><code>$imgl = $_GET['img1'];
  $img2 = $_GET['img2'];
  
  
  $dest = imagecreatefromjpeg('$imgl');
  $src = imagecreatefromgif('$img2');
  
  // Copy and merge
  imagecopymerge($dest, $src, 10, 10, 0, 0, 100, 47, 75);
  
  // Output and free from memory
  header('Content-Type: image/gif');
  imagegif($dest);
  
  imagedestroy($dest);
  imagedestroy($src);
  </code></pre>
  
  <p>However the image that is displayed is just shows a non image icon. The variables $img1 and $img2 contain an image path, to a folder where the images exsist. I know this because when I echo the two variables in a html img tag, both images are displayed. Can anyone tell me where my script is going wrong?</p>