Watermark Maker
Using GD library, input image will be marked with a watermark
*= = = = = = = = = **= = = = = = = = = **= = = = = = = = = **= = = = = = = =
= **= = = = = = = = = **= = = = = = = = =
**# Files that should exist
*
JOAO-4:watermark seara$ ls -R -l
total 48
drwxr-xr-x@ 4 seara staff 136 May 4 12:37 img
-rw-r--r-- 1 seara staff 51 May 11 2009 index.html
-rw-r--r--@ 1 seara staff 14007 May 11 2009 watermark.png
-rw-r--r-- 1 seara staff 752 May 11 2009 watermarkMaker.php
./img:
total 40
-rw-r--r--@ 1 seara staff 20084 Apr 9 2009 myimage.jpg
*
**= = = = = = = = = **= = = = = = = = = **= = = = = = = = = **= = = = = = =
= = **= = = = = = = = = **= = = = = = = = = *
*# test.html file*
<h1>Watermark test</h1> <img src="img/myimage.jpg">
*
**= = = = = = = = = **= = = = = = = = = **= = = = = = = = = **= = = = = = =
= = **= = = = = = = = = **= = = = = = = = = *
*# watermarkMaker.php file*
<?php
// watermark_wrapper.php
// Path the the requested file
$path = $_SERVER[`DOCUMENT_ROOT`].$_SERVER[`REQUEST_URI`];
// Load the requested image
$image = imagecreatefromstring(file_get_contents($path));
$w = imagesx($image);
$h = imagesy($image);
// Load the watermark image
$watermark = imagecreatefrompng(`watermark.png`);
$ww = imagesx($watermark);
$wh = imagesy($watermark);
// Merge watermark upon the original image
imagecopy($image, $watermark, $w-$ww, $h-$wh, 0, 0, $ww, $wh);
// Merge watermark upon the original image (center image)
//imagecopy($image, $watermark, (($w/2)-($ww/2)), (($h/2)-($wh/2)), 0, 0,
$ww, $wh);
// Send the image
header(`Content-type: image/jpeg`);
imagejpeg($image);
exit();
?>
Go Back