Add Watermark on Image using PHP

Add Watermark on Images using PHP

Every photographer (either he is a professional or a newbie) wants to protect his images and creations. For this puppose, he uses watermark. PHP also have ability to add a watermark on images. PHP uses its GD library to write text on images using true type fonts.

To add a watermark, you need an image and any font with extension ttf. For example, I will use “arail.ttf” in my tutorial. Image type can be any from this list

  • jpg / jpeg
  • png
  • gif
  • wbmp

I have a custom functiom for adding watermark on images. This function accepts two parameters as described below

$imagePath (string):  You will give the image path here.

$waterMarkText (string): You will give the watermark text here.