Watermark is the most using method to copyright images. You can protect your websites images using image watermark. PHP helps to create watermark automatically when you upload an image in your website and when you execute this image in your website. You don't need to do that manually PHP will do that for you. Let's see how PHP will do that for you. We are going to create a PHP script for that and we will use PHP imagecopymerge() function for do that. create a file name as watermark.php and write down this code into the script.
watermark.php
<?php
header('content-type: image/jpeg');
$src = $_GET['src'];
$path = pathinfo($src);
$watermark = imagecreatefrompng('watermark.png');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
if ($path['extension']=='png')
$image = imagecreatefrompng($src);
else if ($path['extension']=='jpg'||$path['extension']=='jpeg')
$image = imagecreatefromjpeg($src);
$size = getimagesize($_GET['src']);
$dest_x = $size[0] - $watermark_width-10;
$dest_y = $size[1] - $watermark_height-10;
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 50);
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);
?>
We need a watermark image for this script, this image will show in every Image as a watermark. We declared it on this script name as watermark.png. In this script we will get image using $_GET['src'] get method then merge this image using imagecopymerge() function. When this script works then all images will merge into a single image and execute as a new image with image watermark.When we execute an image file into watermark format then we need to call image address like this
http://example.com/watermark.php?src=image_filename.jpg
If you do tasks before correctly then this script will execute image with watermark. this script will show image watermark via watermark.php script.
You can protect your website images and confirm your authority using this watermark method. It's most popular method for websites. Hope you can understand this tutorial correctly. If you face any problem you can comment here.