Jump to content

PHP WaterMark Code Question


devain

Recommended Posts

Hello

I am currently working on some watermark code for a site everything works great as far as the code that I am going to post below my question is when l link to the image what I would like to do is when the person right clicks on the image I would like it to download the png overlay instead of the image and I am not sure how to accomplish this below is the code and How I pull the image and overlay from the file.

[code]

//session_start();

$db_host = '';
$db_user = '';
$db_pwd = '';
$db_name = '';
mysql_connect($db_host, $db_user, $db_pwd) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());   


$res=mysql_query("select imageno, picture2 from image where id='$id'");
$data=mysql_result($res,0,"imageno");
$dir=mysql_result($res,0,"picture2");

//session_start();
header('content-type: image/jpeg');

$imagesource =  $dir;
$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 = @imagecreatefrompng('watermark.png');
$imagewidth = imagesx($image);
$imageheight = imagesy($image); 
$watermarkwidth =  imagesx($watermark);
$watermarkheight =  imagesy($watermark);
$startwidth = (($imagewidth - $watermarkwidth)/2);
$startheight = (($imageheight - $watermarkheight)/2);
imagecopy($image, $watermark,  $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight);
imagejpeg($image);
imagejpeg($image);
imagedestroy($watermark);
imagedestroy($image);

[code]


this is the image tag that pulls the image

<img src="http://www.domain.com/showp1.php?&id={id}"  >


any help would be appericated
[/code][/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.