dragoninasia2014 2011-01-25 05:13
浏览 49
已采纳

如何使用PHP GD显示动态生成的内嵌图像

I am trying the generate an image on the fly by merging images using PHP GD. I want to know if there is a way I can display the image inside my webpage without the need of storing it somewhere on server.

Like for example I created the following code for merging the images...

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);
}

Now my html code till now was...

<div class="sidebar-avatar">
   <img src="avatar_pattern.png" class="pattern1" width="430" height="100" />
</div>

How should I call the php function so that it displays the image generated in the div I have designated for it.

Update: I found the use of Content-type: image/png but that would mean I will have to display the image on a separate page not inline.

  • 写回答

3条回答 默认 最新

  • dongye1934 2011-09-09 13:33
    关注

    Convert it to Base64 with base64_encode and echo it as a dataURI in an img tag !

    Inline Images with Data URLs

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?