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

Jerome Alet alet@unice.fr
Fri, 1 Jun 2001 14:43:32 +0200 (MET DST)


On Fri, 1 Jun 2001, [iso-8859-1] Max M=F8ller Rasmussen wrote:

> > From: Jerome Alet [mailto:alet@unice.fr]
>=20
> > import PIL.Image
>=20
> > 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.
>=20
> What about something in these lines (untested)?
>=20
> logo =3D getattr(self, "logo")
> from StringIO import StringIO
> fromZope =3D StringIO() # tempfile in memory
> fromZope.write(logo.data) # save the data from Zope
> MyPILImage =3D PIL.Image.open(fromZope)

We mustn't use this line:

> fromZope.close()

It works ONLY if I don't close fromZope, otherwise MyPILImage is unuseable
because PIL seems to use the provided file id, not duplicate it in some
way.

THANKS FOR ALL !

[OT] do you know why my transparent GIF appears with a pink background on
screen and paper when  printed through ReportLab ? I've already noticed
this problem but can't explain it.

bye, and thanks again

Jerome Alet