Base64编码图像

我正在为Firefox / IE构建一个开放式搜索附加组件,并且该图像需要经过Base64编码,因此如何对我拥有的收藏夹图标进行64位编码?


我只熟悉PHP


HUH函数
浏览 536回答 3
3回答

胡子哥哥

据我记得,图像数据有一个xml元素。您可以使用此网站对文件进行编码(使用上载字段)。然后,只需将数据复制并粘贴到XML元素即可。您也可以这样使用PHP来做到这一点:&nbsp;<?php&nbsp; &nbsp; &nbsp; &nbsp; $im = file_get_contents('filename.gif');&nbsp; &nbsp; &nbsp; &nbsp; $imdata = base64_encode($im);&nbsp; &nbsp; &nbsp;&nbsp;?>&nbsp;使用Mozilla指南获取有关创建OpenSearch插件的帮助。例如,icon元素的用法如下:<img width="16" height="16">data:image/x-icon;base64,imageData</>imageData您的base64数据在哪里。

拉风的咖菲猫

检查以下示例<?php&nbsp; &nbsp; // First get your image&nbsp; &nbsp; $image = 'path-to-your-picture/image.jpg';&nbsp; &nbsp; $picture = base64_encode(file_get_contents($image));&nbsp; &nbsp; echo '<img width="100" height="100" src="data:image/jpg;base64,'. $picture .'" />'&nbsp; &nbsp; ?>
打开App,查看更多内容
随时随地看视频慕课网APP