bulldogric Posted March 25, 2009 Share Posted March 25, 2009 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. Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 25, 2009 Share Posted March 25, 2009 <?php $watermark = imagecreatefrompng('/gallery_collegewomen2006/admin/msc_watermark.png'); ?> Quote Link to comment Share on other sites More sharing options...
bulldogric Posted March 25, 2009 Author Share Posted March 25, 2009 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 Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 25, 2009 Share Posted March 25, 2009 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); ?> Quote Link to comment Share on other sites More sharing options...
POG1 Posted March 25, 2009 Share Posted March 25, 2009 See if this works.. <?php $watermark = imagecreatefrompng(__PATH__.'/gallery_collegewomen2006/admin/msc_watermark.png'); ?> Quote Link to comment Share on other sites More sharing options...
bulldogric Posted March 25, 2009 Author Share Posted March 25, 2009 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? Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 25, 2009 Share Posted March 25, 2009 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); ?> Quote Link to comment Share on other sites More sharing options...
bulldogric Posted March 25, 2009 Author Share Posted March 25, 2009 OK, tried it. Now the box is black. I also changed the transparency to 40 ... still get a black box. Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 25, 2009 Share Posted March 25, 2009 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. Quote Link to comment Share on other sites More sharing options...
bulldogric Posted March 25, 2009 Author Share Posted March 25, 2009 unfortunately, this doesn't work -- no error messages, but the photos won't show in the gallery. they're all .jpg what if the watermark was a .jpg? would that work? Quote Link to comment Share on other sites More sharing options...
bulldogric Posted March 26, 2009 Author Share Posted March 26, 2009 But as I re-read this, .jpg can't do transparency. I know I've seen it work properly, just don't know how it was done. Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 26, 2009 Share Posted March 26, 2009 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. Quote Link to comment Share on other sites More sharing options...
bulldogric Posted March 26, 2009 Author Share Posted March 26, 2009 That fixed it! Just have to darken up the watermark! Thanks so much -- I greatly appreciate your help. Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 28, 2009 Share Posted March 28, 2009 Not a Problem, Please mark this solved. 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.