PHP 7 Script to Add Colorful Text Watermark With Custom Font to Images Using GD Library in Browser Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments

 

Welcome folks today in this blog post we will be adding colorful text watermark with custom font to images using gd library using php 7. All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to make an index.php file and copy paste the following code

 

 

index.php

 

 

 

<?php
  
  header('Content-type: image/jpeg');

  
  $image = imagecreatefromjpeg('image.jpg');

  
  $textcolor = imagecolorallocate($image, 255, 255, 255);

  
  $font_file = 'myfont.ttf';

  
  $custom_text = "Watermark Text";

  
  imagettftext($image, 225, 0, 3450, 3000, $textcolor, $font_file, $custom_text);

 
  imagejpeg($image);

 
  imagedestroy($image); // for clearing memory
?>

Leave a Reply