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

时间:2010-07-14 13:39:13

标签: php gd graphic

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

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

2 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

您需要使用GD创建<img>来源或<div>背景,然后在其上单独输出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);
相关问题