Watermark

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
FireLord
Forum Newbie
Posts: 6
Joined: Fri Mar 20, 2009 5:44 am

Watermark

Post by FireLord »

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Code:

I want to create a watermak of the exists image "rotheps.GIF" (the font exists in that path).

Code: Select all

<?php
        $image = "rotheps.GIF";
        echo "<b>Immagine passata: </b><br><br><img src=\"".$image."\" /><br>";
        $im = imagecreatefromgif($image);
        
        $white = imagecolorallocate($im, 255, 255, 255);
        $grey = imagecolorallocate($im, 128, 128, 128);
        $black = imagecolorallocate($im, 0, 0, 0);
        imagefilledrectangle($im, 0, 0, 399, 29, $white);
        $text = 'Testing...';
        $font = "/WINDOWS/Fonts/TIMES.TTF";
        
        $result = imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
        
        echo "<br><br><b>Immagine watermark: </b><br><br><img src=\"".$result."\" /><br>";
?>
Although the first echo prints me rotheps.GIF, the second one doesn't print me the watermark image, with the error: "File does not exist: c:/... /resource id"

I've tried to print $im, and it said "Resource id #3".

Help me pliiiz.


pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Watermark

Post by pickle »

Are you adding a watermark to the rotheps.GIF file? If so, you'll need to save it as a gif, imagettftext doesn't do that. Then, rather than echoing $result, echo $image again.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply