Base64 Encoded Images for Internet Explorer

Tags:

Some interesting development with Base64 Encoded Images for Internet Explorer.

The basic idea is to embed images into the HTML code so as to avoid external dependencies on image files stored elsewhere.

MHTML (Mime/HTML) is essentially how HTML email does it. Microsoft supports the mTHM or mHTML format, but Mozilla is still working on it,

Data URL is probably the most elegent way. Apparently Netscape/Firefox and other browsers already support them. Except for IE, of course.

<img src="data:image/gif;base64,R0lGODlhDwAPAKECAAAAzMzM/////
wAAACwAAAAADwAPAAACIISPeQHsrZ5ModrLlN48CXF8m2iQ3YmmKqVlRtW4ML
wWACH+H09wdGltaXplZCBieSBVbGVhZCBTbWFydFNhdmVyIQAAOw=="

alt="Base64 encoded image" width="150" height="150"/>

 

That ghastly mess will produce the following image in most decent browsers:

Base64 encoded image

 

For IE, there is a server-based solution:

Internet Explorer does not support Base64 encoding of images so we will take advantage of PHP’s built-in base64_decode function. We will simply pass the Base64 data back to a PHP module which will then decode the data and return the appropriate image.

 

I disagree with the following comment:

Got me fooled there for a while, though you had managed to hack ie to allow data uri:s for images. Unfortunately the usefulness of ‘inline images’ is greatly reduced if implemented on the server side. As that would be pretty much the same as requesting a static image. Really impressed with the rest of IE7 through.

  • Comment by: Emil
  • Posted: 2005/06/06 2:18 pm
For me, a direct application for this technique is web info archiving, where you don’t want pages and images to be stored in different places.

What this solution means is that one could serve embedded HTML directly to non-IE browsers, and use the server-side option for non-supportive ones, including IE. That’s a winner to me. 

7 Responses to “Base64 Encoded Images for Internet Explorer”

  1. gary Says:

    Got it to work on Wordpress/firefox. Need to disable WYSIWYG editor, because it automatically adds the site URL to before “data:”

  2. Phi Tran Says:

    I have posted a workaround to translate the base64 to XBM using mask and other MS filter to make the XBM become a color bitmap - The implementation is of your horizon. I have seen some very exortic color pictures only create and displayed using- XBM. This will not require a communication with the server.

    Please look I have discuss it (at several localtionof the net)

    Thanks.

  3. Frank Says:

    I’ve written this into an ASP class using an ADO stream object and an MSXML2.DOMDocument object using bin.base64 datatype and it works very nicely in Firefox but fails entirely in IE. Am I missing something here? Is IE’s implementation as bad as … everything else it tries to do?

  4. gary Says:

    Don’t know why IE wouldn’t work. This was written more than a year ago. Haven’t check with IE7. But I am very happy with Firefox and there is little motivation to even download IE7.

  5. purifier Says:

    yes, IE doesn’t work on that. i tried it myself.

  6. chiz Says:

    Good post. You make some great points that most people do not fully understand.

    “MHTML (Mime/HTML) is essentially how HTML email does it. Microsoft supports the mTHM or mHTML format, but Mozilla is still working on it,

    Data URL is probably the most elegent way. Apparently Netscape/Firefox and other browsers already support them. Except for IE, of course.”

    I like how you explained that. Very helpful. Thanks.

  7. PSP Internet Says:

    Yeh ….I tried it and i had no luck

Leave a Reply

If the above Image does not contain text, use this secure code: nuqjRLXJV