我如何将 GD 即时创建的图像包含到 php 或 phtml 文件中?
<?php
header("Content-type: image/png");
$im = @imagecreate(110, 20)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>
我怎样才能将此图像包含到我的 php 或 html 文件中 放置 >
不保存图片并给出路径是否可以。
<?php
header("Content-type: image/png");
$im = @imagecreate(110, 20)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>
How Can i include this image to my php or html file on fly by just
putting an <img src="<? echo $im?>" />
Is it possible without saving the image and giving the path.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我看到的唯一方法是使用 data-URI< /a>,并将
base64_encode()
图像内容写入那 ;它将获得一个标签,例如这个(引用 来自我链接到的维基百科页面的示例):
But note it will not work with all browsers.
The only way I see would be to use data-URI, and to
base64_encode()
the content of your image into that ; which would get an<img>
tag such as this one (quoting an example from the wikipedia page I linked to) :But note it will not work with all browsers.
有助于阅读 PHP 手册页,注释提供了一些很好的信息。
http://www.php.net/manual/en/book.image .php#93393
Helps to read the PHP Man pages, the comments provide some good information.
http://www.php.net/manual/en/book.image.php#93393