Watch Youtube Video (HINDI) :
In his post, we will do how to add a watermark on the image using PHP. When you are working with the image application and want to add a watermark on the image then this post will help you to add it. it's simple to add a watermark logo on the image.
We will add the logo on the png image to take an example. Therefore we need two images, the first image is what you want to add as a watermark and the second thing is the main image on this image you want to add.
to get done watermark add to the image, we need to set the header content type for the image generated. then after we will give the width and height where you want to add the logo watermark.
Logo:
This is our simple logo.

Image:
This is our png image. On this image's bottom left I want to add above mentioned logo.

Code Example
You just create a simple PHP file. in this file paste all the given codes. You just need to give your image path and watermark image path add.
<?php
header('content-type: image/png');
$sourceImage = 'image.png'; // ADD IMAGE PATH
$myWatermark = imagecreatefrompng('logo.png'); // WATER MARK LOGO PATH
$watermarkWidth = imagesx($myWatermark);
$watermarkHeight = imagesy($myWatermark);
$image = imagecreatefrompng($sourceImage);
$imageSize = getimagesize($sourceImage);
$wmX = $imageSize[0] - $watermarkWidth - 20;
$wmY = $imageSize[1] - $watermarkHeight - 20;
imagecopy($image, $myWatermark, $wmX, $wmY, 0, 0, $watermarkWidth, $watermarkHeight);
imagepng($image, time().'.png'); // SAVE IMAGE
imagepng($image); // SHOW IMAGE
imagedestroy($image);
imagedestroy($myWatermark);
Output With Watermark:

We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- Zoom API Integration with PHP
- How to Make/Create/Write JSON File Using PHP Array In Laravel - PHP
- Simple WhatsApp Messages Send Using Chat API In PHP
- Get IP PHP Function Example - ip_info()
- Get Full Address From Latitude Longitude Google Map API In PHP
- How To Add Google reCAPTCHA v2 In HTML Form Based PHP/Laravel Website
- How Do Check Whether The Email Address Valid Email Or Not In PHP Example
- Call to undefined function Gregwar\Captcha\imagecreatetruecolor()
- Firebase Notification Send Example
- How to connect database with php