jarvis Posted February 22, 2010 Share Posted February 22, 2010 Hi All, Hope someone can point out the obvious! The following code positions my watermark graphic to the top left hand corner: $imagesource = $_GET['path']; $filetype = substr($imagesource,strlen($imagesource)-4,4); $filetype = strtolower($filetype); if($filetype == ".gif") $image = @imagecreatefromgif($imagesource); if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource); if($filetype == ".png") $image = @imagecreatefrompng($imagesource); if (!$image) die(); $watermark = @imagecreatefromgif('watermark.gif'); $imagewidth = imagesx($image); $imageheight = imagesy($image); $watermarkwidth = imagesx($watermark); $watermarkheight = imagesy($watermark); $startwidth = (($imagewidth - $watermarkwidth)/100); $startheight = (($imageheight - $watermarkheight)/100); imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight); #imagecopy($image, $watermark, 0, 0, $watermarkwidth, $watermarkheight); imagejpeg($image); imagedestroy($image); imagedestroy($watermark); Altering: $startwidth = (($imagewidth - $watermarkwidth)/100); $startheight = (($imageheight - $watermarkheight)/100); To $startwidth = (($imagewidth - $watermarkwidth)/0); $startheight = (($imageheight - $watermarkheight)/0); Positions the watermark to the middle. How can I set it to the top right? Many Thanks Quote Link to comment https://forums.phpfreaks.com/topic/192925-watermark-position/ Share on other sites More sharing options...
jarvis Posted February 22, 2010 Author Share Posted February 22, 2010 Sussed it: $startwidth = (($imagewidth - $watermarkwidth)); $startheight = "0"; Quote Link to comment https://forums.phpfreaks.com/topic/192925-watermark-position/#findComment-1016132 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.