Esküvő

Add transparent watermark to image PHP

HTML

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

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

PHP

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.

<?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 »


Esküvő


Related articles

Redirect www to non www with .htaccess RewriteRule

Redirect www to non www with .htaccess RewriteRule

05/12/2015

Redirect your websites visitors from www.domain.com to domain.com without www.

Email Validation

Email Validation

08/02/2013

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

04/02/2013

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 baby *


Find us on Facebook

Tags

Esküvő

Back to Top