note 74831 added to control-structures.while

From: Date: Mon, 30 Apr 2007 06:12:24 +0000
Subject: note 74831 added to control-structures.while
Groups: php.notes 
Request: Send a blank email to php-notes+get-125967@lists.php.net to get a copy of this message
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 ---- Server IP: 64.71.164.2 Probable Submitter: 70.134.71.35 ---- Manual Page -- http://www.php.net/manual/en/control-structures.while.php Edit -- https://master.php.net/note/edit/74831 Del: integrated -- https://master.php.net/note/delete/74831/integrated Del: useless -- https://master.php.net/note/delete/74831/useless Del: bad code -- https://master.php.net/note/delete/74831/bad+code Del: spam -- https://master.php.net/note/delete/74831/spam Del: non-english -- https://master.php.net/note/delete/74831/non-english Del: in docs -- https://master.php.net/note/delete/74831/in+docs Del: other reasons-- https://master.php.net/note/delete/74831 Reject -- https://master.php.net/note/reject/74831 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125967) next »