Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Base64 Encoding Image

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

like image 334
UnkwnTech Avatar asked Aug 30 '08 11:08

UnkwnTech


People also ask

What is Base64 encoding for images?

Base64 encoding is a way to encode binary data in ASCII text. It's primarily used to store or transfer images, audio files, and other media online. It is also often used when there are limitations on the characters that can be used in a filename for various reasons.

Does Base64 encoding reduce image quality?

Encoding to/from Base64 is completely lossless.

Can we convert image to Base64?

Convert Images to Base64Just select your JPG, PNG, GIF, Webp, or BMP picture or drag & drop it in the form below, press the Convert to Base64 button, and you'll get a base-64 string of the image. Press a button – get base64. No ads, nonsense, or garbage. Drag and drop your image here!

How do I decode Base64 image data?

After converting image, you can download this as png file / picture. This tool helps you to convert your Base64 String to image with Ease. Base64 encoding tool supports loading the Base64 text File to transform to Image. Click on the Upload File button and select File.


2 Answers

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.

like image 63
Ross Avatar answered Sep 28 '22 11:09

Ross


$encoded_data = base64_encode(file_get_contents('path-to-your-image.jpg'));     
like image 20
thefreeman Avatar answered Sep 28 '22 10:09

thefreeman