我正在尝试通过使用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);
}
Run Code Online (Sandbox Code Playgroud)
现在我的HTML代码到现在为止......
<div class="sidebar-avatar">
<img src="avatar_pattern.png" class="pattern1" width="430" height="100" />
</div>
Run Code Online (Sandbox Code Playgroud)
我应该如何调用php函数,以便它显示在我为其指定的div中生成的图像.
更新:我发现使用Content-type: image/png但这意味着我必须在单独的页面上显示图像而不是内联.