Search code examples
phpimagecopying

imagecopymerge not responding


I am trying to merge two images with image copy merge. This is the code I have:

<?php

$unframedPhoto = ('unframedPhoto.jpg');
$frame = ('frame.jpg');

imagecopymerge($frame, $unframedPhoto, 200, 200, 0, 0, 800, 800,0);

header('Content-Type: image/jpeg');
imagejpeg($frame, 'framedImage.jpg');

?>

That's the only code in my script. I am executing it by going to the .php file on my localhost, and I am getting no response. I do not see a new image 'framedImage.jpg' in my directory.

Any ideas what's going on here?


Solution

  • 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);