Add transparent watermark to image PHP


watermark-photo.jpg is the photo what will be watermarked.

<img src="watermark.php?photo=watermark-photo.jpg" alt="" />


This script creates a new image form the given photo and the watermark. It centers the watermark in front of the background photo. Name the file as watermark.php.

// load the watermark and the photo
$watermark = imagecreatefrompng('watermark.png');
$photo = imagecreatefromjpeg($_GET[photo]);

// center watermark on the photo
$wx = imagesx($photo)/2 - imagesx($watermark)/2;
$wy = imagesy($photo)/2 - imagesy($watermark)/2;

imagecopy($photo, $watermark, $wx, $wy, 0, 0, imagesx($watermark), imagesy($watermark));
imagejpeg($photo, NULL, 100);

Demo »


Related articles

Redirect www to non www with .htaccess RewriteRule

Redirect www to non www with .htaccess RewriteRule


Redirect your websites visitors from to without www.

Email Validation

Email Validation


Learn how to validate email on client side with HTML5, Javascript and on server side with PHP.

Generate Thumbnail on the Fly with PHP

Generate Thumbnail on the Fly with PHP


In a previous artice I already showed you how to generate square thumbnails with PHP. Now I show you how to keep the original ratio of the image and how to control the alignment of the square image.

1 comment

sachin2013-07-24 11:17

Images are not getting as transparent a white background coming with the watermark

Leave a comment

We welcome any comment from you! Please keep in mind that comments are moderated and rel='nofollow' is in use. So, please do not use a domain as your name or a spammy keyword, or your comment will be deleted.

Name: *

E-mail: *

Message: *

Click on the car *

Find us on Facebook



Back to Top