Jump to content

watermark position


jarvis

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/192925-watermark-position/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.