Base64 Encoding Image


Question

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?

I am only familiar with PHP

1
61
8/30/2008 11:01:31 AM

Accepted Answer

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.

You could also use PHP to do this like so:

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

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</>

Where imageData is your base64 data.

79
4/20/2014 8:50:25 AM

$encoded_data = base64_encode(file_get_contents('path-to-your-image.jpg'));    

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon