Menu

Add Watermark Image in PHP | Create Watermark in PHP

PHP By Feb 19, 2016 1 Comment

Add watermark image in PHP its our new tutorial. You can add your watermark image to your image. Now you dont need to open Photoshop and do this. Here is the very simple and short code for adding your image.

addWaterMark("Your path to image");
function addWaterMark($filename){
$logoImage = imagecreatefrompng('logo.png');
$logoWidth=imagesx($logoImage);
$logoHeight=imagesy($logoImage);
$im = imagecreatefromjpeg($filename);
$sx = imagesx($im);
$sy = imagesy($im);
imagecopymerge($im, $logoImage, ($sx-$logoWidth)/2, ($sy-$logoHeight)/2, 0, 0, $logoWidth, $logoHeight, 20);
imagejpeg($im, $filename);
imagedestroy($im);
}


In the above code we have created a function you have to just call the function and pass the filename as the parameter.

Hop you like the above code. If you face any issue than please let me know or comment below

Author

Hello i am Vivek Moyal PHP developer and writes tutorials for students and beginners. Love to explore new cities

1 Comment

  1. raman says:

    Hello Sir,
    Can i add this watermark in pdf file every page.

Leave a comment

Your email address will not be published. Required fields are marked *