View Single Post
Old 02-07-2010, 09:54 AM  
Oracle Porn
Affiliate
 
Oracle Porn's Avatar
 
Industry Role:
Join Date: Oct 2002
Location: Icq: 94-399-723
Posts: 24,433
Quote:
Originally Posted by AdultStoriesNow View Post
Or if your site is in PHP you could do something like this:

Code:
$base_dir = getcwd(); // meh
$f_file = $base_dir . $file;
$w_file = $base_dir . "/watermarked/".$file;
$water_file = $base_dir.'watermark.png';

$file = $_GET['file']; // Add security measures
header("Content-Type: image/jpeg");

if(!file_exists($f_file)) {
   readfile($base_dir . "invalid_image.jpg");
   exit;
}

if(!file_exists($w_file)) {
   readfile($w_dir);
   exit;
}

//Borrowed from http://articles.sitepoint.com/article/watermark-images-php as this is in a quick reply box so won't be writing new code as this is an example/idea :P

$watermark = imagecreatefrompng($water_file);
$watermark_width = imagesx($watermark);  
$watermark_height = imagesy($watermark);  
$image = imagecreatetruecolor($watermark_width, $watermark_height);  
$image = imagecreatefromjpeg($f_file);
$size = getimagesize($f_file);  
$dest_x = $size[0] - $watermark_width - 5;  
$dest_y = $size[1] - $watermark_height - 5;  
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);  
imagejpeg($image);  
imagedestroy($image);  
imagedestroy($watermark);

//Some code here to put the watermarked image into $base_dir . 'watermarked/'.$file so the image is cached for next time
thanks ill try it, i can't edit that actually page but only the css header and footer (not actually content aka thumbs)...thats the script i use
__________________



Last edited by Oracle Porn; 02-07-2010 at 09:55 AM..
Oracle Porn is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote