ZahidRasheed
12/16/2016 - 9:29 AM

merge.php

<?php
//Set Variables:
$background = "bg.jpg"; //Background chose by user
$logo = "logo.png"; //This logo will always remain same
$userLogo = "20.png"; //Logo created by user. 
$savePath = "/output/"; //Where to Save?
$showNotSave = true;

//No need to change anything below....
$bgImage = imagecreatefromjpeg($background);

//Apply Logo
$img = imagecreatefrompng($logo);
list($logoWidth, $logoHeight) = getimagesize($logo);
imagecopy($bgImage, $img, 30, 0, 0, 0, $logoWidth, $logoHeight);
imagedestroy($img);

//Apply Custom Logo
$img = imagecreatefrompng($userLogo);
$wx = imagesx($bgImage) / 2 - imagesx($img) / 2;
$wy = imagesy($bgImage) / 2 - imagesy($img) / 2;
imagecopy($bgImage, $img, $wx, $wy, 0, 0, imagesx($img), imagesy($img));
imagedestroy($img);

if ($showNotSave) {
    header('Content-Type: image/png');
    imagepng($bgImage);
} else {
    imagepng($bgImage, $savePath);
}
imagedestroy($bgImage);
?>