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); 
4

2 回答 2

0

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

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

于 2010-08-21T03:37:17.157 回答
0

您需要使用 GD 创建<img>源或<div>背景,然后在它们上面分别输出 HTML。GD是纯像素泵浦

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

图像.php

   header('Content-type: image/png'); 
   $image = imagecreatetruecolor(...);
   // GD generation stuff
   imagepng($image);
于 2010-08-21T04:16:29.440 回答