Hi, We have Zope 2.3.1 installed, running with Python 1.5.2, and python image library 1.1.1, on a PC with SUSE Linux 7.1. 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: Error Type: AttributeError Error Value: _save ... /db1/Zope-2.3.1-linux2-x86/Extensions/feature_view.py, line 114, in draw_segment File /usr/local/lib/python1.5/site-packages/PIL/Image.py, line 674, in save File /usr/local/lib/python1.5/site-packages/PIL/PngImagePlugin.py, line 410, in _save AttributeError: (see above) feature_view.py, line 114 corresponds to the im.save line The funny thing is that a img.png file is saved to disk, but is corrupted, but we still can see the correct image from xv, according to the im.show() call. Any idea on what the prob might be?? Thanks Francisco Andreas
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/
participants (2)
-
Francisco Silva Domingues -
Jason Byron