gerkintrigg Posted June 27, 2007 Share Posted June 27, 2007 hello I'm using the code below to make a watermark and it's kinda working, but I want it semi-transparent as the PNG file is itself. Is there an easy way of overlaying transparent images in the GD library, so that the original image is merged in such as way that it can be seen through the watermark? Thanks... code to follow. header('content-type: image/jpeg'); $watermark = imagecreatefrompng('watermark.png'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg($_GET['src']); $size = getimagesize($_GET['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); Link to comment https://forums.phpfreaks.com/topic/57379-solved-transparent-watermarks-on-images/ Share on other sites More sharing options...
Barand Posted June 27, 2007 Share Posted June 27, 2007 try adjusting the last argument in the imagecopymerge() to get the desired effect. BTW, the first is redundant: $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg($_GET['src']); Link to comment https://forums.phpfreaks.com/topic/57379-solved-transparent-watermarks-on-images/#findComment-283869 Share on other sites More sharing options...
gerkintrigg Posted June 27, 2007 Author Share Posted June 27, 2007 That's not exactly what I was looking for, but thanks. That did solve another problem. ;o) My main issue now is: The watermark PNG has transparent areas in it. Is there any way of preserving these areas like I can in photoshop when layering images with transparent backgrounds. I hope that makes sense. Link to comment https://forums.phpfreaks.com/topic/57379-solved-transparent-watermarks-on-images/#findComment-283879 Share on other sites More sharing options...
Barand Posted June 27, 2007 Share Posted June 27, 2007 My png image I used with your code has a transparent background which remains transparent even when the setting is 100 ??? Link to comment https://forums.phpfreaks.com/topic/57379-solved-transparent-watermarks-on-images/#findComment-283911 Share on other sites More sharing options...
gerkintrigg Posted June 27, 2007 Author Share Posted June 27, 2007 could you try it with: http://build.nextdaygraphics.com/includes/watermark.php?src= and let me know what happens please Barand? Link to comment https://forums.phpfreaks.com/topic/57379-solved-transparent-watermarks-on-images/#findComment-283936 Share on other sites More sharing options...
Barand Posted June 27, 2007 Share Posted June 27, 2007 That link just displayed the URL Link to comment https://forums.phpfreaks.com/topic/57379-solved-transparent-watermarks-on-images/#findComment-283988 Share on other sites More sharing options...
gerkintrigg Posted June 27, 2007 Author Share Posted June 27, 2007 http://build.nextdaygraphics.com/includes/watermark.php?src=<path to your image goes here> ? Link to comment https://forums.phpfreaks.com/topic/57379-solved-transparent-watermarks-on-images/#findComment-283996 Share on other sites More sharing options...
Barand Posted June 27, 2007 Share Posted June 27, 2007 Attached zip with screenshots of your png and mine (same jpeg background) [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/57379-solved-transparent-watermarks-on-images/#findComment-284013 Share on other sites More sharing options...
gerkintrigg Posted June 27, 2007 Author Share Posted June 27, 2007 Thanks Barand. It seems I had wrong settings when exporting from photoshop. All sorted now. Link to comment https://forums.phpfreaks.com/topic/57379-solved-transparent-watermarks-on-images/#findComment-284060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.