Jump to content

need help


bulldogric

Recommended Posts

I run a Web site, and a year ago I paid someone to create a custom Flash gallery. All in all, it works pretty well. But there are some problems, and the person who did the work no longer replies to my email.

 

With the help of my host provider and some online research, I have it close to working the way it should. The biggest issue is that a script that processes the images is supposed to place a watermark, but isn't. It is creating a spot for the watermark, but it isn't putting in the actual watermark.

 

I have almost no knowledge of PHP, and my host provider said they can't help me with this problem, so I'm wondering if anyone out there can tell me what the problem is.

 

Here is the part of the script that deals with the watermark.

 

------------------------------------------------------------------

 

if($pieces[4]=="slides"){

          $transparency = 40;                                    // watermark's transparency (0-100)

          $watermark = imagecreatefrompng('msc_watermark.png');    // watermark stored in admin folder placed in variable $watermark

          $watermark_width = imagesx($watermark);

          $watermark_height = imagesy($watermark);

          $image = imagecreatefromjpeg($imageDestination);    // store image that we want to process in variable $image

          $size = getimagesize($imageDestination);

          $dest_x = $size[0] - $watermark_width - 100;

          $dest_y = $size[1] - $watermark_height - 100;

          imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 40);

          imagejpeg($image, $imageDestination);

          imagedestroy($image);

          imagedestroy($watermark);

          echo "Watermark created on ".$imageDestination."<br />";

 

------------------------------------------------------------------

 

The watermark is in the admin folder and is named msc_watermark.png

http://madisonsoccercentral.com/gallery_collegewomen2006/admin/msc_watermark.png

 

The rest of the script appears to work fine.

 

Any help would be greatly appreciated. Thank you.

Link to comment
Share on other sites

I tried that and got ...

 

---------------------------------------

 

Warning: imagecreatefrompng(/gallery_collegewomen2006/admin/msc_watermark.png) [function.imagecreatefrompng]: failed to open stream: No such file or directory in /home/(xxxxx)/public_html/gallery_collegewomen2006/admin/functions.php on line 324

 

Warning: imagesx(): supplied argument is not a valid Image resource in /home/(xxxxx)/public_html/gallery_collegewomen2006/admin/functions.php on line 325

 

Warning: imagesy(): supplied argument is not a valid Image resource in /home/(xxxxx)/public_html/gallery_collegewomen2006/admin/functions.php on line 326

 

Warning: imagecopymerge(): supplied argument is not a valid Image resource in /home/(xxxxx)/public_html/gallery_collegewomen2006/admin/functions.php on line 331

 

Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/(xxxxx)/public_html/gallery_collegewomen2006/admin/functions.php on line 334

 

--------

 

functions.php is the PHP script with the watermark information in it

 

Link to comment
Share on other sites

Basicly your issue comes down to the fact that you need the real path of the image from your script, or else it will not work. I do not know if the image is even where you are telling me, because it is your server and I am guessing.

But try this: (Note: Please Convert the (xxxxx) back to the correct directory.)

<?php
$real_file=is_file('/home/(xxxxx)/public_html/gallery_collegewomen2006/admin/msc_watermark.png');
if($real_file===TRUE) {
    $watermark = imagecreatefrompng('/home/(xxxxx)/public_html/gallery_collegewomen2006/admin/msc_watermark.png');    
}
//Option 2: If you get real desperate we can also look into the realpath() function.
$real_path=realpath('msc_watermark.png');
$watermark = imagecreatefrompng($real_path);
?>

Link to comment
Share on other sites

Thanks for the help!

 

No errors using this, but still the same problem -- a box where the watermark should be, but no watermark.

 

----------------------------------

 

$transparency = 100; // watermark's transparency (0-100)

$real_file=is_file('/home/madisons/public_html/gallery_collegewomen2006/admin/msc_watermark.png');

if($real_file===TRUE)

    $watermark = imagecreatefrompng('/home/madisons/public_html/gallery_collegewomen2006/admin/msc_watermark.png');   

$watermark_width = imagesx($watermark);

$watermark_height = imagesy($watermark);

$image = imagecreatefromjpeg($imageDestination); // store image that we want to process in variable $image

$size = getimagesize($imageDestination);

$dest_x = $size[0] - $watermark_width - 100;

$dest_y = $size[1] - $watermark_height - 100;

imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 40);

imagejpeg($image, $imageDestination);

imagedestroy($image);

imagedestroy($watermark);

echo "Watermark created on ".$imageDestination."<br />";

 

----------------------------------

Got the same thing with Option 2.

 

I also tried the one with __PATH__., but I got errors

 

Here is the watermark

http://www.madisonsoccercentral.com/gallery_collegewomen2006/admin/msc_watermark.png

 

Here is the gallery (click on the pix folder for Option 1 result, test folder for Option 2 result)

http://www.madisonsoccercentral.com/gallery_collegewomen2006/

 

 

Is there other information I can provide that might help find the problem?

 

Link to comment
Share on other sites

Try this let me know the results.

Replace:

<?php
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 40);
?>

With:

<?php
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
?>

Link to comment
Share on other sites

The reason is that jpeg does not support alpha color transparency, so the image will have to be png format, if that is OK with you then do this.

Replace:

<?php
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 40);
imagejpeg($image, $imageDestination); 
?>

With:

<?php
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 40);
imagepng($image, $imageDestination); 
?>

This should solve your problem.

Link to comment
Share on other sites

jpeg does not support Alpha transparancy, but the function will still fade the image, that is the number 40 in action Thus you still get a watermark affect. Although perhaps not ideal.

So make both images jpeg and use that correct imagejpeg() function, then merge them with the same parameters using imagecopymerge() . Let me know how it turns out.

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.