Dear friends, I need a help about image watermarking. I want to use text watermarking on fly/on call/on access an image. The following code works fine (if GD enabled). But the page that shows the watermarked image don't allow me to put another texts/ html codes etc. Actually I want to display the watermarked image on a page where there are many other html contents. So please tell me how can I do that or if you have another solution then PLEASE PLEASE tell me. Thanks in advance. <?php //load image $im = imagecreatefromjpeg('img.jpg'); //figure out where to put the text $imagesize = getimagesize('img.jpg'); $x_offset = 7; $y_offset = $imagesize[1] - 20; //allocate text color $textcolor = imagecolorallocate($im, 0xFF, 0xFF, 0xFF); //write out the watermark imagestring($im, 5, $x_offset, $y_offset, 'My watermark', $textcolor); //output watermarked image header('Content-type: image/jpg'); imagejpeg($im); ?> Code (markup):
Could you try explaining that in a bit more detail? I cannot for the life of me even figure out what you are asking for... "But the page that shows the watermarked image don't allow me to put another texts/ html codes" -- that bit of broken engrish in particular I cannae make the least bit of sense out of.
You will need to have an intermediate page. Let's say the above code is in image.php, you will show the user the page showImage.php, which includes your HTML/PHP and then the image.php image: <?php echo 'Your image <img src="image.php" />'; PHP:
If you'd pay a bit more attention to what he asks for, you'd understand as we all did that the user wanted to include some "html code" besides the image itself on the respective page. Though, that's not possible since you're sending a content-type : "image/jpg" or whatever. As the above users commented, you need to include the image in the page you're needing it to be by using either <img src , either some div with a background-image from css.