我想创建一个图像从html,我不能使用painty,因为它已经过时,不再工作,我想要类似的东西。 我已经尝试使用GD库这样从html创建图像
<?php
$html_code = "<b> this is the body </b> ";
// Create the image
$img = imagecreate("300", "600");
imagecolorallocate($img,0,0,0);
$c = 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);
// Display the image
header("Content-type: image/jpeg");
imagejpeg($img);
创建图像,但它不“编译” html标签和打印他们的图像文本英寸
问候
您的意思是它打印'这是身体'?这很正常。这是Web浏览器呈现html标记的工作。在PHP文档的imagettftext页面上有一些提示。 http://php.net/manual/fr/function.imagettftext.php – Aif
'imagettftext'不会将HTML作为输入,而是纯文本 - 所以你不能这样做。 – Andris