gpt4 book ai didi

php - 从 html 创建图像

转载 作者:搜寻专家 更新时间:2023-10-31 20:51:36 25 4
gpt4 key购买 nike

我想从 html 创建一个图像,我不能使用 painty,因为它已经过时并且不再工作,我想要类似的东西。我已经尝试过像这样使用 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 库无法渲染 html 代码并将其绘制在图像上。如果你想绘制粗体文本,你需要使用粗体,例如arialbd.ttf

关于php - 从 html 创建图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6923865/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com