Page 1 of 1

Watermark

Posted: Fri Mar 20, 2009 10:33 am
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.

Re: Watermark

Posted: Fri Mar 20, 2009 12:24 pm
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.