Jump to content

Using GD to merge two images (like a watermark)


nbarone

Recommended Posts

I am trying to merge two images... the background image will have an overlay that is basically a border around the image...

 

Here is my code, but it's only outputting the background image and not the overlay.

<?php	

// define base image, this is the custom image
$background = "../images/frontpage/fpgtest.png";
$overlay = "../images/assets/fpgraphic_overlay.png";

// create image
$background = imagecreatefrompng($background);
$overlay = imagecreatefrompng($overlay);

// define colors
$white = imagecolorallocate($background, 255, 255, 255); // transparent

// apply trans color
//imagealphablending($background, true);
//imagesavealpha($background, true);
//imagecolortransparent($background, $white); 

// define header
header ("Content-type: image/png"); 

// Merge Image
 imagecopymerge($background,$overlay,0,0,0,0,0,0,100);


// display image
imagepng($background);
imagedestroy($background);

?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.