Akhil Sahu Akhil Sahu - 5 months ago 23
PHP Question

Merge two image created using php

How can i merge two image created from url two url like:

Merge these two images:

`$url1=https://imageare.com/nc/Aud/tr.php?track=426413219-.wav&ignorable_duration=1.0

$url2=https://imageare.com/nc/Aud/tr.phptrack=426413219_chan1.wav&ignorable_duration=1.0


Not same as the possible duplicate: Image not fetched

Answer

To merge two images like shown here and assuming that images are in png .You might need to use following code:

$url1=https://imageare.com/nc/Aud/tr.php?track=426413219-.wav&ignorable_duration=1.0
$url2=https://imageare.com/nc/Aud/tr.phptrack=426413219_chan1.wav&ignorable_duration=1.0
$dest = imagecreatefrompng($url1);
$src = imagecreatefrompng($url2);
imagecopymerge($dest, $src, 0, 0, 0, 0, 500, 100, 90);

The following can be used to output image to browser

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