devain Posted January 3, 2007 Share Posted January 3, 2007 HelloI 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] Quote Link to comment Share on other sites More sharing options...
AndyB Posted January 4, 2007 Share Posted January 4, 2007 Plan B: create a div with height and width to match your image. Using CSS, set your image as a background to the div. Set the transparent overlay image as content of the div. Quote Link to comment 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.