How to Add Text Watermark to Image in PHP?
This simple article demonstrates of php add watermark text to image. you will learn how to add watermark text to image in php. I would like to show you php add text on image as watermark. I explained simply about add text watermark to image php. Alright, let’s dive into the steps.
Sometimes we want to add a website domain name as a watermark on each image of your website. Then I will give you a very simple example of how to add a text watermark to image in PHP. so let's simply follow below code and make it done.
Here, You need to put one image call "watermark-php-text.png". Then you have to download font from google fonts and put in folder. You can download from here: Download Font.
Let's copy below code and create index.php file.
$sourceImage = "watermark-php-text.png";
$imagetobewatermark = imagecreatefrompng($sourceImage);
$white = imagecolorallocate($imagetobewatermark, 51, 102, 0);
$image = imagecreatefrompng($sourceImage);
$imageSize = getimagesize($sourceImage);
$wmX = $imageSize - 380;
$wmY = $imageSize - 20;
imagettftext($imagetobewatermark, $fontsize, 0, $wmX, $wmY, $white, $font, $watermarktext);
For Save Image
I hope it can help you...
We are Recommending you
- PHP implode() Function Example Tutorial
- How to Convert Array to String in PHP?
- PHP explode() Function Example Tutorial
- How to Convert String into Array in PHP?
- How to Upgrade PHP Version from 8.0 to 8.1 in Ubuntu?
- PHP - How to Remove Blank Pages from PDF File?
- How to Install Phpmyadmin in Ubuntu Server?
- How to Calculate Age from Date of Birth in PHP?
- How to Subtract Hours from DateTime in PHP?
- PHP Add Hours to Datetime Example
- How to Partially Hide Email Address in PHP?
- How to use Google Maps API with JQuery PHP?