Brian W Posted June 3, 2009 Share Posted June 3, 2009 I can't seem to figure out why this code won't overlay my watermark.png file over the image. $target_path = "images/"; $name = date("ymd").basename($_FILES['uploadedfile']['name']); $target_path = $target_path . $name; if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { $o['name'] = $target_path; list($o['width'], $o['height']) = getimagesize($o['name']); if($o['width'] > $o['height']){ $n['width'] = 400; $n['height'] = round(($o['height']/$o['width'])*400); } else { $n['height'] = 400; $n['width'] = round(($o['width']/$o['height'])*400); } $src = imagecreatefromjpeg($o['name']);//Create Handle $watermark = imagecreatefrompng('watermark.png'); $tmp=imagecreatetruecolor($n['width'],$n['height']); imagecopyresampled($tmp,$src,0,0,0,0,$n['width'],$n['height'],$o['width'],$o['height']); imagecopy($tmp, $watermark, 0, 0, 0, 0, 400, 400); imagejpeg($tmp,$o['name'],100);//Output I found one person somewhere that said something about the version of the GD library they got (packaged with RedHat) had a bug in imagecopy(), but I'm thinking I'm just f'ing up. Link to comment https://forums.phpfreaks.com/topic/160819-solved-issue-with-watermarking/ Share on other sites More sharing options...
Brian W Posted June 3, 2009 Author Share Posted June 3, 2009 What it does: Nothing at all besides resize it. What I want it to do: Take original image, resize it (which works) and add the watermark. Help please, this one is stumping me Link to comment https://forums.phpfreaks.com/topic/160819-solved-issue-with-watermarking/#findComment-848804 Share on other sites More sharing options...
Brian W Posted June 4, 2009 Author Share Posted June 4, 2009 bump (sorry, would really like some input) Link to comment https://forums.phpfreaks.com/topic/160819-solved-issue-with-watermarking/#findComment-849408 Share on other sites More sharing options...
roopurt18 Posted June 4, 2009 Share Posted June 4, 2009 I've never used the PHP image functions to do such a thing, so I know nuts about them. But maybe one of these will help you: http://www.google.com/search?rlz=1C1GGLS_enUS330US330&sourceid=chrome&ie=UTF-8&q=php+add+a+png+watermark Link to comment https://forums.phpfreaks.com/topic/160819-solved-issue-with-watermarking/#findComment-849510 Share on other sites More sharing options...
Brian W Posted June 4, 2009 Author Share Posted June 4, 2009 been there, done that... the top couple of results were places I'd already gone to. I've done all but copy and paste their code and try that. Link to comment https://forums.phpfreaks.com/topic/160819-solved-issue-with-watermarking/#findComment-849518 Share on other sites More sharing options...
roopurt18 Posted June 4, 2009 Share Posted June 4, 2009 Fair enough. You'd be surprised though how many people ask for help without making a solid attempt on their own though. The next step would be to try and get more information as to why it's failing. Turn on error reporting if it's not already. See if those image*() functions have a way of returning extended error information and check that information at every step of the way. And double check your version of any extension you're using for known bugs and / or problems. If all else fails, upload or send me a copy of your png and if I have time I can try to run it on my machine. Link to comment https://forums.phpfreaks.com/topic/160819-solved-issue-with-watermarking/#findComment-849556 Share on other sites More sharing options...
Brian W Posted June 4, 2009 Author Share Posted June 4, 2009 Excuse me while I kick myself... this entire time there hasn't been any issue whatsoever besides me overwriting the incorrect file (wrong directory on in the ftp!). What tipped me off was setting error_reporting to E_ALL and not receiving any errors whatsoever. Thanks for your help, sorry I inconvenienced you and any one else who looked at this topic. Link to comment https://forums.phpfreaks.com/topic/160819-solved-issue-with-watermarking/#findComment-849571 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.