title: PHP Merge 2 Images (Insert Face To An Image)
body: <p>I need your help</p>
  
  <p>I have two images,<br />
  1. <a href="http://i.imgur.com/pyWGk.jpg" rel="noreferrer">http://i.imgur.com/pyWGk.jpg</a> (face image, type: jpeg)<br />
  2. <a href="http://i.imgur.com/LYk07.png" rel="noreferrer">http://i.imgur.com/LYk07.png</a> (frame image, with hole in face, type: png)<br /></p>
  
  <p>I want insert face image into frame image</p>
  
  <p>I tried this script</p>
  
  <pre><code>&lt;?php
  $image = imagecreatefromjpeg('face.jpg');
  $frame = imagecreatefrompng('ironman.png');
  
  $iw = imagesx($image);
  $ih = imagesy($image);
  
  $fw = imagesx($frame);
  $fh = imagesy($frame);
  
  imagealphablending($frame, true);
  imagesavealpha($frame, true);
  imagecopy($image, $frame, 0, 0, 0, 0, $fw, $fh);
  
  header('Content-Type: image/jpeg');
  imagejpeg($image);
  
  imagedestroy($image);
  imagedestroy($frame);
  ?&gt;
  </code></pre>
  
  <p>The problem are:<br />
  Resolution of result image doesn't same with resolution of frame image, and<br />
  How to change position of face image, so the face image can right on hole in frame image</p>