note 74831 deleted from control-structures.while by felipe
| From: | felipe@php.net | Date: | Tue, 29 Jan 2008 11:17:55 +0000 |
| Subject: | note 74831 deleted from control-structures.while by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-135506@lists.php.net to get a copy of this message | ||
Note Submitter: remotehams.com
----
my simple script to 'tile' a watermark
<?php
// (c) 2006, Brandon Hansen [kg6ypi]
//
// watermark.php
// 4/29/2007 11:05:00 PM
header('content-type: image/jpeg');
// your watermark image
$watermark = imagecreatefrompng('watermark.png');
// grab watermarks deminsions
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
// your image to be watermarked
$image = imagecreatefromjpeg($_GET['file']);
// grab the size of image to be watermarked
$size = getimagesize($_GET['file']);
// find last watermarks postitions
$dest_x = $size[0] - $watermark_width;
$dest_y = $size[1] - $watermark_height;
// begin postition
$c_dest_x = 0;
$c_dest_y = 0;
// loop/tile watermark until image full
while ($dest_x > $c_dest_x && $dest_y > $c_dest_y)
{ // insert wartermark
imagecopymerge($image, $watermark, $c_dest_x, $c_dest_y, 0, 0, $watermark_width,
$watermark_height, 100);
// math for new watermark postition
if ($c_dest_x < $dest_x)
{ $c_dest_x = $c_dest_x + $watermark_width; }
if ($c_dest_x > $dest_x && $c_dest_y < $dest_y)
{ $c_dest_x = 0;
$c_dest_y = $c_dest_y + $watermark_height;
}
}
// do GD stuff
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);
?>
hope this helps someone, i couldn't find an example anywhere! so i give one, hi hi
73's kg6ypi