Online: 103   Members: 4,232

Adding Watermark Protection To Your Images

Adding your logo to images can be a very useful technique in both preventing hotlinking and preventing from the use of your images without your name on them. This is also a reasonably simple process. First of all we need to define the page as an "image" so that the browser will display it correctly.

<?php
header ("Content-type: image/png");

Next, we need to load in the background image which will be whatever image you are attempting to watermark.

$background = imagecreatefrompng("backgroundimage.png");

Now, lets load in our overlay which in this case would be your logo png.

$insert = imagecreatefrompng("overlay.png");

Lastly, we need to combine them now

imagecolortransparent($insert,imagecolorat($insert,0,0));
$insert_x = imagesx($insert);
$insert_y = imagesy($insert);
imagecopymerge($background,$insert,0,0,0,0,$insert_x,$insert_y,65);
imagepng($background,"",100);
?>

The '65' in the imagecopymerge() function serves as an alpha number. In other words, if you were to make it 100 the image would show at full intensity, by placing it at 65 we reduce the alpha level slightly so that it is still visible but not intrusive on the image itself.

Related Tutorials

Useful Resources