james_byrne Posted July 23, 2008 Share Posted July 23, 2008 I would like to have a script on my site to eather watermark images on the fly, or to actually save the watermarked images. I have found this tutorial and it seems to work great, all except when the images is suppose to get displayed it does not show the image but instead shows wired caracters, like if you opend a jpg image in notepad. I just know i am missing something. But with this script is there anyway to save the watermarked image. Let me know please. Thank you A link to the script: http://www.sitepoint.com/article/watermark-images-php Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 23, 2008 Share Posted July 23, 2008 How are you calling the image? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 23, 2008 Share Posted July 23, 2008 You can save the images by specifying the filename parameter in the imagejpeg() function. As for the odd output, did you remember to send a proper header? If you did, then try uncommenting that line and the imagejpeg() line and check to see if you get any errors displayed. I can't remember which of these problems results in the odd output. Quote Link to comment Share on other sites More sharing options...
james_byrne Posted July 24, 2008 Author Share Posted July 24, 2008 ok so here is the code i am using, that is not working. But my current problem has changed a little bit, i have got it to display the image now, but it displays it with a box in the corner that has a black background then my watermark in that box. The watermark is a transparent png image though. and that should allow it to work the way i want it to. Below is my code, please let me know if you can help. Thanks in advance for the help. <? header('content-type: image/jpeg'); $src = "upload/cat15-id33.jpg"; $watermark = imagecreatefrompng('watermark.png'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg($src); $size = getimagesize($src); $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); ?> Quote Link to comment Share on other sites More sharing options...
james_byrne Posted July 27, 2008 Author Share Posted July 27, 2008 ok, i have found out that the code i am using was not that great, the article uses some wrong things. I have fixed it up now though. The only issue i am having is centering the watermark. I think the most effective way to do that though. Would be through making the watermark image larger. And making it centered. I appreciate all your guyses help. 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.