Login Register

Sending image dynamically to the browser.

Hi All,
Is there any way in which I can send a dynamically generated image from the server to the browser. On thing that comes to my mind is (I am using Java on the server side). I would read an Image on the server using streams, base64encode it... and send it Via AJAX to the browser. The Browser in turn using a base64decoder will get the bytes again...

1. What NEXT? now if I have the image in the form of bytes... how do I display it on the screen?
2. Will any browser stop me from doing this?

Regards,
Yazad

The data: url supports this

The data: url supports this in some browsers, but IE isn't one of them. You'd have to hack around it for that browser..something like http://dean.edwards.name/weblog/2005/06/base64-ie/

Dustin Machi

Thank you :)

I can't thank you enough Dustin. Highly appreciated. This will most likely solve my problem. Thank you again.

Regards,
Yazad

Just a head's up...

...you'd be much better off (if you have control over the server, which is sounds like you do) to have the server send the byte stream out as image/[something], and simply use that URL in your image tag. Decoding a large byte stream from base64 is possible, and using the data: url is as well, but the simplest and most efficient solution is to let the server generate that.

image display

I have a similar requirement to display a set of images (am looking at the thumbnail viewer widget within dojo). Now how do I convert the byte stream coming from the server (actually a domino attachment from web service) into a URL - do i need to store it at a central location and then serve up the images through http ?