我正在尝试使用 PHP GD 合并图像来动态生成图像。我想知道是否有一种方法可以在我的网页中显示图像,而不需要将其存储在服务器上的某个位置。
例如,我创建了以下代码来合并图像......
function create_image() {
$main_image = imagecreatefrompng("images/main.png");
$other_image = imagecreatefrompng("images/other.png");
imagecopy($main_image, $other_image, 114, 53, 0, 0, 49, 34);
imagepng($main_image);
imagedestroy($other_image);
}
现在我的 html 代码到现在为止是......
<div class="sidebar-avatar">
<img src="avatar_pattern.png" class="pattern1" width="430" height="100" />
</div>
我应该如何调用 php 函数,以便它显示我为其指定的 div 中生成的图像。
Update: 我发现使用Content-type: image/png
但这意味着我必须在单独的页面上显示图像而不是内联。
使用base64_encode 将其转换为Base64 并将其作为img 标签中的dataURI 进行回显!
带有数据 URL 的内嵌图像
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)