How to add watermark to an image using PHP

This is tutorial about how to add watermark to an image using PHP.Watermarks are use full to display copyright information or name of your website on any image.In this process you need two images first is the watermark image and second is image on which watermark will display.Follow these steps to add watermark to an image using PHP.

1.Choose image paths,output format and transparency –Assign the relative path of watermark image to variable $watermark_path and path of original image to $image_path.Choose the format of output image from PNG,JPEG and GIF.Remember that output image format does not depends on both image.$pct is the transparency of watermark image varies from 0 to 100.

2. Create resource of both images-Depending on types of images create resources for both images.Here is the function for creating image resource.The function is given below.

3.Get width and height of images-Using PHP function imagesx() and imagesy()get the width and the height of both images.

4.Merge both images-Using imagecopymerge() merge both images.

5.Output the image-Set headers and send the image to the browser.Here is the function that perform same task.

Here is the complete code.

 

 

 

 

  • Some of these tutorials
    are extremely good, magazine like. Thanks for sharing!