images on the web

Matt Nordhoff mnordhoff at mattnordhoff.com
Fri Jun 20 02:33:21 EDT 2008


chris wrote:
> I'm creating a data plot and need to display the image to a web page.
> What's the best way of doing this without having to save the image to
> disk? I already have a mod_python script that outputs the data in
> tabular format, but I haven't been able to find anything on adding a
> generated image.

You could use data: URIs [1].

For example, a 43-byte single pixel GIF becomes this URI:

<data:image/gif;base64,R0lGODlhAQABAIAAAP%2F%2F%2F%2F%2F%2F%2FyH5BAEAAAEALAAAAAABAAEAAAICTAEAOw%3D%3D>

They don't have universal browser support, but that might not be a
problem in this case.

As for generating them with Python, I'm not sure... I just used Hixie's
data: URI kitchen [2] for the above example.

[1] <http://tools.ietf.org/html/rfc2397>
[2] <http://software.hixie.ch/utilities/cgi/data/data>
-- 



More information about the Python-list mailing list