Re: imagecreate

From: Date: Wed, 08 Feb 2006 15:00:21 +0000
Subject: Re: imagecreate
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-230092@lists.php.net to get a copy of this message
On 8 Feb 2006, at 14:20, Ross wrote:
I am trying to replace the images in a page with this code <?
          $im = imagecreatetruecolor(400, 30);
          $ross = imagecolorallocate($im, 203, 116, 0);
     $font = 'simran__.ttf';
           $text = 'chicken pakora';
           imagettftext($im, 20, 0, 10, 20, $ross, $font, $text);
             imagepng($im);
               imagedestroy($im);
               ?>
This is fine here... http://www.ecurry.net/example1.php http://www.ecurry.net/example2.php but when I try and embed in inside a html page I get a garbled mess http://www.ecurry.net/menu6.php http://www.ecurry.net/menu6.phps I know this has something to so with the header but cannnot work it out! I tried header("Content-type: image/png"); before the output but I get a garbled mess and the header error.
You need to output the png content type header before the call to imagepng(). If you get a garbled mess the chances are that your script is not 'clean'. In other words, you have output some data elsewhere in your script. This could be something as simple (and invisible) as a carriage-return after your closing PHP tag. Cheers, Rich -- http://www.corephp.co.uk Zend Certified Engineer PHP Development Services

« previous php.general (#230092) next »