我使用這個腳本使用PHP-GD庫,使HTML代碼轉換成圖像的圖像:轉換的HTML工作不
<?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);
?>
網站網址:
http://almogas.com/temp/phpimage.php?id=3
我得到很多的未知字符。我該如何解決這個問題?
///////////////////////////////////////////////
編輯
現在它的工作後,刪除空格
但沒有辦法添加背景圖片? 謝謝
您應該使用PNG而不是JPG你是什麼意思與_unknown char_?你如何期待這個工作? – putvande
「Content-Type」標題未正確發送。該文檔具有Content-Type「text/html」。 –
OP試圖創建一個像這樣不正確的'內容Type' @Le_Morri – putvande