You have unwanted chars before <?
. remove all blank lines and spaces before <?
your image is otherwise correct.
<?
must be the first character first line in your script. you can avoid ?>
if you use it it must be the last line last chars.
Вопрос
I use this script to make html code into image using php-gd library:
<?php
//put your html code here
$html_code = '
<html>
<body>
Image Out Put sadadasdasdasdasdasd
</body>
</html>
';
$img = imagecreate("300", "600");
imagecolorallocate($img,0,0,0);
$c2 = imagecolorallocate($img,70,70,70);
imageline($img,0,0,300,600,$c2);
imageline($img,300,0,0,600,$c2);
$white = imagecolorallocate($img, 255, 255, 255);
imagettftext($img, 9, 0, 1, 1, $white, "arial.ttf", $html_code);
header('Content-type: image/jpeg');
imagejpeg($img);
?>
site url:
http://almogas.com/temp/phpimage.php?id=3
I get lot of unknown characters. How can I fix this behavior?
///////////////////////////////////////////////
edit
now its working after delete the spaces
but there is way to add background image? thank you
Решение
You have unwanted chars before <?
. remove all blank lines and spaces before <?
your image is otherwise correct.
<?
must be the first character first line in your script. you can avoid ?>
if you use it it must be the last line last chars.
Другие советы
Please make sure that your file start without spaces or extra chars. It is important that it starts with
<?
You can avoid the closing
?>
So that you're sure to not send any other unwanted output to the client.