[Zope] problem with PIL .save

Jason Byron jason_zope@yahoo.com
Thu, 17 May 2001 15:25:31 -0700 (PDT)


> 
> When we run the following code from python we have no prob,
> we get the rectangle image file img.png, and we also see it
> in xv according to the im.show()
> 
>     import Image, ImageDraw
>     im = Image.new("RGB",(200,200))
>     draw = ImageDraw.Draw(im)
>     draw.rectangle((10,10,100,150), fill=(255,255,255))
>     del draw
>     im.show()
>     im.save("/usr/tmp/img.png","PNG")
> 
> Now the problem is when we use the same code in a python
> external
> method called from zope. we get the following error:
> 
> 

don't know if this will help but I've used PIL in Zope before
and I use code like this to get an image:


from cStringIO import StringIO
import PIL


image = PIL.Image.new("RGB",(40,40))

...

outFile = StringIO()
image.save(outFile, "GIF")
outFile.seek(0)
outString = outFile.read()
return outString

>
>

I believe save tries to save to disk, and StringIO lets
you do the same commands but uses memory instead.

never tried PNG image though

hth,

jason




__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/