Do like this...
<?php
$unframedPhoto= imagecreatefromjpeg('unframedPhoto.jpg');
$frame = imagecreatefromjpeg('frame.jpg');
imagecopymerge($frame, $unframedPhoto, 200, 200, 0, 0, 800, 800,0);
header('Content-Type: image/jpeg');
imagejpeg($frame);
imagedestroy($frame);
imagedestroy($frame);