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.
This is our simple logo.
This is our png image. On this image's bottom left I want to add above mentioned logo.
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 - $watermarkWidth - 20; $wmY = $imageSize - $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)
We Are Also Recommending You :
- could not encode content to iso-8859-1
- Firebase Dynamic Links Shorten URL PHP Function
- Zoom API Integration with PHP
- How To Get Youtube Video Thumbnail From URL In PHP - Laravel
- Zaakpay Payment gateway Integration Tutorial PHP
- How Do Check Whether The Email Address Valid Email Or Not In PHP Example
- Match Function Php 8
- Get IP PHP Function Example - ip_info()
- How To Check Valid Integer Values Using PHP Function Example
- How To Check Given URL Is Valid Or Not PHP Function Example