[Zope] PIL+Zope: what's wrong with this code ?

Max Møller Rasmussen maxm@normik.dk
Fri, 1 Jun 2001 12:49:10 +0200


> From: Jerome Alet [mailto:alet@unice.fr]

> import PIL.Image

> I'm really not sure about the two first parameters that the
> PIL.Image.fromstring() function need, the first one is the mode, the
> second is the size.

What about something in these lines (untested)?

logo = getattr(self, "logo")
from StringIO import StringIO
fromZope = StringIO() # tempfile in memory
fromZope.write(logo.data) # save the data from Zope
MyPILImage = PIL.Image.open(fromZope)
fromZope.close()

Then you ought to have it in "MyPILImage"

regards Max M