top of page

PHP Watermark

Writer's picture: rdouttrdoutt

Updated: Aug 14, 2020


<?php

/*

=============================================================

Script Name: watermark.php4

Verion: 1.0

Author: Ryan Doutt

Date: April 2007

Acknowledge: Brock Ferguson - See original article at http://www.sitepoint.com/article/watermark-images-php

which this script is based.

This is a PHP scripted, watermarking system for graphics files to be used with .htaccess on

an Apache web server. It should be called as follows from within your root .htaccess file:

RewriteEngine on

RewriteCond %{REQUEST_URI} uploads(.*) [NC]

RewriteRule ^(.*)$ http://www.yourdomain.com/path/to/watermark.php4?src=$1 [NC]

To see this script in action please point your favorite browser in the general direction of

one of the following images:

http://www.1800getryan.com/uploads/certaldo/P6180228.JPG

http://www.1800getryan.com/uploads/ireland/P8230023.JPG

http://www.1800getryan.com/uploads/broumov/P5240187.JPG

This script is available for use as freeware subject to the retention of the preceding

information and acknowledgements in any copy or modification that is made to this code.

=============================================================

*/

header('content-type: image/jpeg');

$watermark = imagecreatefrompng('watermark.png');

$watermark_width = imagesx($watermark);

$watermark_height = imagesy($watermark);

$image = imagecreatefromjpeg($_GET['src']);

$size = getimagesize($_GET['src']);

$dest_x = $size[0] - $watermark_width;

$dest_y = $size[1] - $watermark_height;

$white = imageColorAllocate ($watermark, 255, 255, 255);

imagecolortransparent($watermark,$white);

imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);

imagejpeg($image);

imagedestroy($image);

imagedestroy($watermark);

?>


10 views0 comments

Recent Posts

See All

PHP Thumbnail

<?php /* ============================================================= Script Name: thumbnail.php Version: 2.0 Author: Ian Anderson Date:...

PHP Random Image

<?php /* ============================================================= Script Name: randomimage.php4 Verion: 2.0 Author: Ryan Doutt Date:...

Comments


T. B.
Veblin
  • Pinterest Social Icon
  • Google+ Social Icon
  • Twitter Social Icon
  • YouTube Social  Icon

All content, including text, is copyrighted material and is protected by International Law. Therefore, any use, including, but not necessarily limited to the reproduction, use on another website, copying and printing requires the prior, authorized permission of 1800getryan.com (All Rights Reserved) © 2001-2018.

bottom of page