dynamic CGI images

Hi,

I'm trying to generate dynamic images, using CGI, with matplotlib. I'd like to have a CGI script return the images directly, instead of having to use savefig() first to write them to a file.

Is there a way to do this?

Trevor

I'm trying to generate dynamic images, using CGI, with matplotlib. I'd like to have a CGI script return the images directly, instead of having to use savefig() first to write them to a file.

Is there a way to do this?

Technically yes.
When you are using the GD backend you can simply savefig to a stdout stream (ie. via savefig(sys.stdout)).

As of version 0.53 you could not do this (meaning write to a stream) directly with the Agg backend. matplotlib wants a file name, but you can't simply give it /dev/stdout (at least on a *nix) because it appends an extension.

So the bottom line is that if you're using GD then you're good to go. With Agg, you can either write to file and then read that in your CGI script, or modify the code that handles the writing - at one point (~v0.50) I did that for GD before it became part of the distro.

Perhaps John can comment on whether he foresees adding write-to-stream functionality with Agg.

ยทยทยท

--
Peter Groszkowski Gemini Observatory
Tel: +1 808 974-2509 670 N. A'ohoku Place
Fax: +1 808 935-9235 Hilo, Hawai'i 96720, USA