[Zope] Returning a pil generated image from a python product

Lennart Regebro lennart@torped.se
Wed, 20 Nov 2002 00:32:32 +0100


From: "Sean K" <getmejazzed@yahoo.com>
> pic = cStringIO.StringIO()

from cStringIO you can get the result as a string right? This could be worth
a try:

  data = pic.getvalue()
  pic.close()
  RESPONSE.setHeader("Content-type", "image/gif")
  RESPONSE.setHeader('Content-Length', len(data))
return data

It probably uses some more memory with big images, but unless you plan on MB
size images it shouldn't be a problem.

><IMG src="./dynamicImage?RESPONSE=RESPONSE">

The RESPONSE=RESPONSE shouldn't really be needed, it should be passed anyway
when called like that.

Best Regards

Lennart Regebro
http://www.easypublisher.com/