图像到浏览器而不保存
如何将图像从内存传输到浏览器而不保存。
例如:
function getImage()
{
$imageFile = imagecreatefromjpeg('Map.jpg');
$imageObject = imagecreatefrompng('image2.png');
imagealphablending($imageFile, true);
imagecopy(....);
$ret = array($imageFile, $imageObject) ;
return $ret
}
<?php $ret = getImage(); ?>
<img src = <?php $ret[0];? alt=''>
如果不保存,这可能吗?
How can I put image from the memory to the browser, without saving.
For example:
function getImage()
{
$imageFile = imagecreatefromjpeg('Map.jpg');
$imageObject = imagecreatefrompng('image2.png');
imagealphablending($imageFile, true);
imagecopy(....);
$ret = array($imageFile, $imageObject) ;
return $ret
}
<?php $ret = getImage(); ?>
<img src = <?php $ret[0];? alt=''>
Is this possible, without saving?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,
只需尝试
imagejpeg($img);
并将其放入渲染图像的 PHP 脚本的
路径中,
请参阅示例:http://php.net/manual/en/function.imagecreatefromjpeg.php
Yes,
Just try
imagejpeg($img);
and put into
<img src=
path to the PHP script which render the imageSee sample at: http://php.net/manual/en/function.imagecreatefromjpeg.php
也许如果您将图像编码为 base64 并像这样使用它,它会起作用:
HTML:
我推断您想在一个请求中执行此操作。
Maybe if you would code your image to base64 and use it like that, it would work:
HTML:
I infered that you want to do this in one request.
您应该有一个发送正确标头的脚本,然后浏览器应将其识别为图像。类似于:
?>
You should have a script which sends proper headers and then it should be recognized as an image by the browser. Something like:
?>