Inserting a matplotlib image in an html image element.

Hello,

My problem is the following : I would like to create an image using the matplolib facilities and then insert this image
in a <IMG SRC="*data*:*image*/???;base64 *.../> *element.
Then using Gecko (mozilla) and python + xpcom, I would try to interact with this image (zoom ...).

In order to succeed I feel I have to understand how a back-end is written.

It seems I have to start with the Figure class.
But then I can't find the image format, the way to return binary data or perhaps base64 data.
I don't want to save the figure in a file et then read it with <IMG SRC="theFile.png"/>.
The speed would be very low.

What is the process to add a new back-end ?

I wish the encode/decode base64 wil not take too much time for keeping the dynamism of gtk back-end (for instance).
What do you think about that ?

Thanks a lot,

Cyril.

You can always get the latest canvas buffer from
figure.canvas.tostring_rgb(). A quick pylab example would be:

from pylab import *
import base64

plot(rand(100))
a = gca()
c = a.figure.canvas
buf = base64.encodestring(c.tostring_rgb())

# I would suggest using PIL
import Image
x = Image.fromstring('RGB', c.get_width_height(), c.tostring_rgb())

# You can then get specific format output strings
s = x.tostring('xbm')

ยทยทยท

On 1/24/06, Cyril Giraudon <cyril.giraudon@...185...> wrote:

Hello,

My problem is the following : I would like to create an image using the
matplolib facilities and then insert this image
in a <IMG SRC="*data*:*image*/???;base64 *.../> *element.
Then using Gecko (mozilla) and python + xpcom, I would try to interact
with this image (zoom ...).

In order to succeed I feel I have to understand how a back-end is written.

It seems I have to start with the Figure class.
But then I can't find the image format, the way to return binary data or
perhaps base64 data.
I don't want to save the figure in a file et then read it with <IMG
SRC="theFile.png"/>.
The speed would be very low.

What is the process to add a new back-end ?

I wish the encode/decode base64 wil not take too much time for keeping
the dynamism of gtk back-end (for instance).
What do you think about that ?

Thanks a lot,

Cyril.

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options