seco Posted April 8, 2008 Share Posted April 8, 2008 Hi i try this code from php.net about writting text on image <?php header("Content-type: image/png"); // Create the image $im = imagecreatetruecolor(400, 30); // Create some colors $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); // The text to draw $text = 'Testing...'; // Replace path by your own font path $font = 'arial.ttf'; // Add some shadow to the text imagettftext($im, 20, 0, 11, 21, $grey, $font, $text); // Add the text imagettftext($im, 20, 0, 10, 20, $black, $font, $text); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); imagedestroy($im); ?> this code gives me warning says "cannot modify header information because is already sent by line 2" any help how to make this code works? thanks in advance. Quote Link to comment Share on other sites More sharing options...
discomatt Posted April 8, 2008 Share Posted April 8, 2008 Probably means you have a line break before your opening <?php tag. Quote Link to comment Share on other sites More sharing options...
seco Posted April 8, 2008 Author Share Posted April 8, 2008 the code i use is as you see i try <?php header("Content-type: image/png"); like that but nothing changed all the page contain is this code only Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 8, 2008 Share Posted April 8, 2008 What type of editor are you using to create the script? Also, what character set are you using to store it. If it is UTF8, there will be a weird character in front of the <?php which gets sent to the browser as output and would generate that message. Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.