Also can be done in this way. Hope this will be useful for future visitors.
$base = imagecreatefrompng('your base image path');
//logo is transparent: in this case stackoverflow logo
$logo = imagecreatefrompng("path for image with transparent background");
//Adjust paramerters according to your image
imagecopymerge_alpha($base, $logo, 60, 60, 0, 0, 300, 200, 100);
header('Content-Type: image/png');
imagepng($base);
//@see: http://php.net/manual/en/function.imagecopymerge.php for below function in first comment
function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct){
// creating a cut resource
$cut = imagecreatetruecolor($src_w, $src_h);
// copying relevant section from background to the cut resource
imagecopy($cut, $dst_im, 0, 0, $dst_x, $dst_y, $src_w, $src_h);
// copying relevant section from watermark to the cut resource
imagecopy($cut, $src_im, 0, 0, $src_x, $src_y, $src_w, $src_h);
// insert cut resource to destination image
imagecopymerge($dst_im, $cut, $dst_x, $dst_y, 0, 0, $src_w, $src_h, $pct);
}
Working Example:
This is background Image
This is stackoverflow logo.
This is combined Result.
