我想从html创建图像,因为它已经过时且不再工作,所以我无法使用画图,我想要类似的东西.
我已经尝试过使用GD库创建图像,像这样
<?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标记并将其作为文本显示在图像中.
最好的祝福
解决方法:
GD lib不具备渲染html代码并将其绘制在图像上的能力.如果要绘制粗体文本,则需要使用粗体,例如arialbd.ttf