beverly Posted September 27, 2006 Posted September 27, 2006 I'm revising existing PHP code and trying to change this: to: an output that adds a textual watermark. I've got part of it (this function) $img = imagecreatefromjpeg($img_src); $white = imagecolorallocate($img, 255, 255, 255); $imagestring($img, 3, 5, imagesy($img)-20, 'Watermark', $white); // header('Content-type: image/jpeg'); imagejpeg($img); I'm just not sure how to "call" the function (passing the $img_src) to display the image rather than using the HTML img. If I include header('Content-type: image/jpeg'); , as recommended, I get an error saying the header is already called (and it is). If I don't include it, I get the image (as bin-hex "text"), rather than the image! Source for above code
beverly Posted September 28, 2006 Author Posted September 28, 2006 NEVER MIND! I figured it out myself 1. Create a file called "v_watermark.php": <?php // Load image $image = imagecreatefromjpeg( '../'.$_GET['pic_path'] ); if ($image == false) { echo 'no image'; die(); } // Add colored text $white = imagecolorallocate($image, 255, 255, 255); imagestring($image, 3, 5, imagesy($image)-20, 'Watermark text', $white); // Display image header('Content-type: image/jpeg'); // header('Content-Disposition: inline; filename=' . $_GET['src'] ); imagejpeg($image); // die(); ?> 2. Then pass the imagepath to the 'page' (even the name of the image dynamically, if desired): Of course, you can have different image types and different color types and change everything about the text based on the size of the image. Try this link for more info: Dynamic Watermarking with PHP
Recommended Posts
This topic is 6700 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now