問題描述
我正在為 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 編碼圖像的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!