Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internet Explorer and Base64 image display

Tags:

In aim to manipulate more easily various images on client side with Javascript, I wrote a function on server side (in VB 2010) to convert a file into a base64 string that I send to the client.

When I tried it in Internet Explorer 8.0 with 3 different images, 1 portrait and 2 landscapes, I realized that only the portrait image was displayed entirely, meanwhile both landscape images were truncated (I can see just the upper part of the image).

I thought I had a bug in my conversion function, until I tried my local page with Firefox: every image is perfectly displayed by Firefox.

So there is my question: Is this a well-known bug of Internet Explorer ? If the answer is yes, Is there a well-known remedy for that well-known bug?

like image 279
BBBreiz Avatar asked Apr 15 '12 04:04

BBBreiz


People also ask

How do I view Base64 encoded images?

Use the img Tag to Display Base64 Image in HTML We can specify the URL of the image in the src attribute of the img tag. We can display base64 images by providing the information about the image in the src attribute. We need to define the accurate content type, content-encoding, and charset in the src attribute.

Does browser cache Base64 images?

Browsers can cache downloaded files. If the Base64 string is in a text (or JSON) file then it can be cached. This data can then be used directly in the HTML (or if JSON, parsed with Javascript and used with HTML).

How do I display an image in base 64 HTML?

Images encoded with Base64 can be embedded in HTML by using the <img> tag. This can help to increase the page load time for smaller images by saving the browser from making additional HTTP requests.


2 Answers

IE8 can only do Base64 URI images up to 32kb in size. It's a marginally annoying limitation, but you can still get by with icons/etc. Keep in mind that Base64 encoded images are on average 33% more data sent down the pipe anyway, so it's... eh, y'know, use your judgement.

For anyone interested, it's also possible to make these work in IE6/7 (without, I might add, that 32kb limit...): http://venodesigns.net/2010/06/17/you-got-your-base64-in-my-css/

like image 141
Ryan McGrath Avatar answered Sep 29 '22 12:09

Ryan McGrath


IE8 is limited to 32KB. One way around this is to just serve the images in 'tiles' where each tile is less than 32KB.

like image 39
Myforwik Avatar answered Sep 29 '22 10:09

Myforwik