在PHP中从文本到图像

在PHP中从文本到图像,php,jquery,image,gd,Php,Jquery,Image,Gd,请查看演示网站 该演示名为“图像标题”,我的下一步是将文本和图像作为一个组转换为图像,这样我就可以单击鼠标右键进行复制和粘贴 然而,有PHP代码允许我将文本转换为图像,但我几乎不知道如何将“图像标题”(demo)转换为HTML 下面是PHP代码示例,但我不知道如何组合它 <?php // Create a 100*30 image $im = imagecreate(100, 30); // White background and blue text $bg = imagecolor

请查看演示网站

该演示名为“图像标题”,我的下一步是将文本和图像作为一个组转换为图像,这样我就可以单击鼠标右键进行复制和粘贴

然而,有PHP代码允许我将文本转换为图像,但我几乎不知道如何将“图像标题”(demo)转换为HTML

下面是PHP代码示例,但我不知道如何组合它

<?php
// Create a 100*30 image
$im = imagecreate(100, 30);

// White background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// Write the string at the top left
imagestring($im, 5, 0, 0, 'Hello world!', $textcolor);

// Output the image
header('Content-type: image/png');

imagepng($im);
imagedestroy($im);
?>

有任何帮助,请告诉我如何从jQuery代码转换成图像


AM

最简单的方法可能是:

// index.html
<img src="render_image.php?text=Hello World" />
//index.html
然后:

// render_image.php
<?php
// Create a 100*30 image
$im = imagecreate(100, 30);

// White background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// Write the string at the top left
imagestring($im, 5, 0, 0, $_GET['text'], $textcolor);

// Output the image
header('Content-type: image/png');

imagepng($im);
imagedestroy($im);
?>
//render_image.php
对javascript代码稍加修改就可以使用它


有关使用$\u GET变量的更多信息:

您可以将示例php代码保存在名为“render\u image.php”的文件中,然后使用GET变量将文本传递给它。ie.
www.site.com/render_image.php?text=HelloWorld
然后在同一代码中,将硬编码字符串更改为
$\u GET['text']
。这里有一些可能会有帮助的链接:是的,我知道这一部分,我已经尝试过了,它不起作用,任何其他想法!我尝试过这一部分,但问题是,当我用jquery代码运行这个示例代码时,结果只是显示未知图像,而我没有通过jquery选择图像并输入图像标题!他们只是通过了那个密码。我几乎不知道我错过了什么。谁能帮帮我吗!