icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » help with watermark wrapper

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old June 5th, 2008, 2:49 AM   #1 (permalink)
Registered User
Seasoned Poster
 
c0c0c0's Avatar
 
Joined in Dec 2003
Lives in Clearwater, Florida
Hosted on Pixel
45 posts
Gave thanks: 0
Thanked 0 times
help with watermark wrapper

Hello smart people,

Since the upgrade to PHP5 the watermark wrapper is not working for me anymore. When I have the .htaccess in the picture folder the pictures are teh broke. I need some help to resolve this.

Here is the .htaccess
Code:
AddHandler watermarked .jpg
AddHandler watermarked .jpeg
AddHandler watermarked .gif
AddHandler watermarked .png

Action watermarked /watermark/wrapper.php
Here is the wrapper.php

Code:
<?php

$watermark = "watermark.png";
$image = $_SERVER["PATH_TRANSLATED"];

if (empty($image)) die();

if (!file_exists($image)) {
   header("404 Not Found");
   echo "File Not Found."; die();
}
$host = ( ! isset($_SERVER['HTTP_HOST'])) ? '' : $_SERVER['HTTP_HOST'];
$referer = $_SERVER['HTTP_REFERER'];

$outputType = getFileType($image);

watermark($image, $watermark, $outputType, $host, $referer);

/**
   Outputs the image $source with $watermark in the lower right corner.
   @param $source the source image
   @param $watermark the watermark to apply
   @param $outputType the type to output as (png, jpg, gif, etc.)
                      defaults to the image type of $source if left blank
*/
function watermark($source, $watermark, $outputType="", $host, $referer) {
   $sourceType = getFileType($source);
   $watermarkType = getFileType($watermark);

   if (empty($outputType)) $outputType = $sourceType;
   if ($outputType == "gif") $outputType = "png"; // Okay to remove after July 2004
   header("Content-type:image/$outputType");

   // Derive function names
   $createSource = "ImageCreateFrom".strtoupper($sourceType);
   $showImage = "Image".strtoupper($outputType);
   $createWatermark = "ImageCreateFrom".strtoupper($watermarkType);

   // Load original and watermark to memory
   $output = $createSource($source);
   $logo = $createWatermark($watermark);
   ImageAlphaBlending($output, true);

   // Find proper coordinates so watermark will be in the lower right corner
   $x = ImageSX($output) - ImageSX($logo);
   $y = ImageSY($output) - ImageSY($logo);

   // Display
   if ( ! isset($referer) OR ! stristr($referer, $host))
   {ImageCopy($output, $logo, $x, $y, 0, 0, ImageSX($logo), ImageSY($logo)); $showImage($output);} else {$showImage($output);}
   

   // Purge
   ImageDestroy($output);
   ImageDestroy($logo);
}

function getFileType($string) {
   $type = strtolower(eregi_replace("^(.*)\.","",$string));
   if ($type == "jpg") $type = "jpeg";
   return $type;
}
quickly looking at this I know it is missing the call to end php but it was working prior with this missing (I didn't write the script)

I do have an error log in the watermark folder
Quote:
PHP Fatal error: Call to undefined function: imagecreatefromphp() ...wrapper.php on line 40
Again this only started happening after the upgrade so I am thinking that imagecreatefrom is different in 5?

Thank your for your input!

...
__________________
blog your news
Crazy Computing!
Vegan?
My Blog

Pixel server.
c0c0c0 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On