I am trying to merge two images using PHP. One is a jpg that I have pulled in the form of a Facebook URL, the other is a "watermark" logo that is a png that I hope to apply in the bottom right hand corner of the Facebook image before posting the image back to Facebook.
I'm having trouble merging the two images. The function below is passed the url of the Facebook image (which is a jpg) $imagedata = the Facebook image URL. The function is currently returning: Resource id#1. I am hoping to save the merged image to the /uploads/ folder as the same previously randomly generated filename and return it's location from the function.
I have previously referenced this page: Merge a png ontop of a jpg and retain transparency with php
function createImage($imagedata) {
$upload_dir = ($_SERVER['DOCUMENT_ROOT'] .'/uploads/');
$filename =generateFilename().'.jpg'; //generateFilename() does nothing more than create a random string to use as a unique filename
$filelocation=$upload_dir . $filename;
file_put_contents($filelocation,file_get_contents($imagedata));
$localimage = $filename;
$dest = imagecreatefromjpeg('/uploads/' . $localimage);
$src = imagecreatefrompng('images/overlay.png');
imagecopyresampled($dest, $src, $src2x, $src2y, 0, 0, $src2w, $src2h, $src2w, $src2h);
//header('Content-Type: image/png');
imagejpeg($dest, 'dickshlitz.jpg', 100);
imagedestroy($dest);
imagedestroy($src); }
Any and all help is deeply appreciated. Please ask questions if I have not been clear enough.