Base64 Encoding Image(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 编码图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Base64 编码图像
基础教程推荐
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
