Merging two images with PHP

homework picture homework · Oct 6, 2010 · Viewed 99.9k times · Source

I'm trying to merge two images together with PHP.

For example... how would I go about placing image one on top of image two or merge, with basic PHP? I have tried something such as watermarking, but it doesn't seem to be working.

Image One

alt text

Image Two

alt text

...and have it turn into this? FINAL RESULT:

alt text

Answer

homework picture homework · Oct 6, 2010

I got it working from one I made.

<?php
$dest = imagecreatefrompng('vinyl.png');
$src = imagecreatefromjpeg('cover2.jpg');

imagealphablending($dest, false);
imagesavealpha($dest, true);

imagecopymerge($dest, $src, 10, 9, 0, 0, 181, 180, 100); //have to play with these numbers for it to work for you, etc.

header('Content-Type: image/png');
imagepng($dest);

imagedestroy($dest);
imagedestroy($src);
?>