[thelist] Hex encode images for HTML emails - how?

Christian Heilmann codepo8 at gmail.com
Thu Jun 11 18:30:05 CDT 2009


Joel D Canfield wrote:
>> Check out this tool, which converts images to data: URIs:
>>
>>      http://www.scalora.org/projects/uriencoder/
>>     
>
> okay, can someone explain that do me, 'cause somehow, despite being a
> lifelong geek, it seems like magical to me.
>
> joel
>
>   
Nothing magical about it. Images are files in a certain byte order. When 
you base 64 encode them and put them in a src attribute with data: uri 
the browser reads the file and renders it as an image. It is pretty much 
the same process that happens when you put images and attachments to 
emails and your email client says "encoding attachments" before it sends 
off the mail as an email needs to be one file stream and not several files.

IE does not support images inline that way, instead you need to encode 
the whole document as MSHTML if you want the same benefit.

The benefit btw is that you don't need to load the images from another 
server, which in the case of email clients is turned off by default (as 
spammers could know that you opened their emails every time the image 
gets requested) and in any other case can be a performance gain as the 
site does not need to http negotiate, get the domain, request the image 
and then render it.





More information about the thelist mailing list