Base64 编码图像 [英] Base64 Encoding Image

查看:51
本文介绍了Base64 编码图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Firefox/IE 构建一个开放式搜索插件,图像需要进行 Base64 编码,那么我如何对我拥有的网站图标进行 Base64 编码?

I am building an open search add-on for Firefox/IE and the image needs to be Base64 Encoded so how can I base 64 encode the favicon I have?

我只熟悉 PHP

推荐答案

据我所知,图像数据有一个 xml 元素.您可以使用此网站对文件进行编码(使用上传字段).然后只需将数据复制并粘贴到 XML 元素即可.

As far as I remember there is an xml element for the image data. You can use this website to encode a file (use the upload field). Then just copy and paste the data to the XML element.

您也可以使用 PHP 来执行此操作:

You could also use PHP to do this like so:

 <?php
        $im = file_get_contents('filename.gif');
        $imdata = base64_encode($im);      
?> 

使用 Mozilla 的指南 获取有关创建 OpenSearch 插件的帮助.比如图标元素是这样使用的:

Use Mozilla's guide for help on creating OpenSearch plugins. For example, the icon element is used like this:

<img width="16" height="16">data:image/x-icon;base64,imageData</>

其中 imageData 是您的 base64 数据.

Where imageData is your base64 data.

这篇关于Base64 编码图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆