如何使用gd库php在图像上编写html?

发布于 2024-09-10 07:56:17 字数 550 浏览 2 评论 0原文

我在 php 中使用 IMAGETTFTEXT 函数在一些图像上写入文本。现在我想在我的图像上写入 html 标签,例如 IMG 标签。 我不知道该怎么做!我需要帮助。 这是我的代码:

$font_file = 'times.ttf';
$font_size=15;          
$image_file= 'new.jpg'; 

$image =  imagecreatefromjpeg($image_file);

$font_color = imagecolorallocate($image, 0, 0, 0);

imagettftext($image, $font_size, 0, 55, 30, $font_color, $font_file, "fhfghfghfghfg ");
imagettftext($image, $font_size, 0, 600, 30, $font_color, $font_file, "aaaaaaa ");

Header("Content-type: image/jpg");

imagejpeg($image);

imagedestroy($image); 

im using IMAGETTFTEXT function in php for writing text on some images.now i want to write html tags on my image,for example IMG tag.
i dont know how to do that!i want help plz.
here is my code :

$font_file = 'times.ttf';
$font_size=15;          
$image_file= 'new.jpg'; 

$image =  imagecreatefromjpeg($image_file);

$font_color = imagecolorallocate($image, 0, 0, 0);

imagettftext($image, $font_size, 0, 55, 30, $font_color, $font_file, "fhfghfghfghfg ");
imagettftext($image, $font_size, 0, 600, 30, $font_color, $font_file, "aaaaaaa ");

Header("Content-type: image/jpg");

imagejpeg($image);

imagedestroy($image); 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故人如初 2024-09-17 07:56:17

除非您编写某种正则表达式来替换超链接等并从中创建图像,否则没有实际的方法可以做到这一点。

尝试使用正则表达式并从标签中提取有用的数据。

There is no actual way to do this unless you write some kind of regular expression that replaces hyperlinks etc and creates an image from them.

Try using regular expressions and extracting useful data from the tags.

情深缘浅 2024-09-17 07:56:17

您需要使用 GD 创建您的 源或

背景,然后在它们之上分别输出 HTML。 GD是纯像素泵送

   <?php ?>
   <div style="background-image: url('/image.php')"><a href="http://example.com>a hyperlink</a></div>

image.php

   header('Content-type: image/png'); 
   $image = imagecreatetruecolor(...);
   // GD generation stuff
   imagepng($image);

you need to use GD to created your <img> sources or <div> backgrounds and then output the HTML separately atop them. GD is pure pixel pumping

   <?php ?>
   <div style="background-image: url('/image.php')"><a href="http://example.com>a hyperlink</a></div>

image.php

   header('Content-type: image/png'); 
   $image = imagecreatetruecolor(...);
   // GD generation stuff
   imagepng($image);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文