[Zope-dev] Zope 2.7.0 and Pythom Image Library
Hi I'm trying to get the PIL(last version on python 2.3) working with Zope, but it seems that it's not working. I use the code: file = StringIO.StringIO(data) im = Image.open(file) im.show() where data is datafrom a blob in a db. This code is working outside Zope, but at once when i try to make it a product in Zope, I get this error: IOError: cannot identify image file Does anyone know what's wrong or what to do to make this work? Thanks for all help! Regards Tor Oskar Wilhelmsen ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Zope 2.7.0 and Pythom Image Library
That was my thought to, but it isn't like that. When I run the code from command line, all works perfectly well. The difference in the command line vs zope is that in the command line the from OFS import SimpleItem is ignored, and I use the class gallerybase: instead of #class gallerybase(SimpleItem.Item): Can the import of SimpleItem, and the inheritance of SimpleItem.Item make som errors?? -TOW - Original Message - From: "Andreas Jung" <[EMAIL PROTECTED]> To: "Tor Oskar Wilhelmsen" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, July 05, 2004 8:33 AM Subject: Re: [Zope-dev] Zope 2.7.0 and Pythom Image Library > If the code works in pure Python then it must work in Zope especially when > you call > the code from an external method or other filesystem-based code as long as > you are using > the same Python version. Your problem looks likely that your input data is > broken. > > -aj > > --On Montag, 5. Juli 2004 8:27 Uhr +0200 Tor Oskar Wilhelmsen > <[EMAIL PROTECTED]> wrote: > > > Hi > > I'm trying to get the PIL(last version on python 2.3) working with Zope, > > but it seems that it's not working. > > > > I use the code: > > file = StringIO.StringIO(data) > > im = Image.open(file) > > im.show() > > > > where data is datafrom a blob in a db. This code is working outside > > Zope, but at once when i try to make it a product in Zope, I get this > > error: > > > > IOError: cannot identify image file > > > > > > Does anyone know what's wrong or what to do to make this work? > > > > Thanks for all help! > > > > > > Regards > > Tor Oskar Wilhelmsen > > > > Andreas Jung > zopyx.com - Software Development and Consulting Andreas Jung ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Zope 2.7.0 and Pythom Image Library
Tor Oskar Wilhelmsen wrote: I'm trying to get the PIL(last version on python 2.3) working with Zope, but it seems that it's not working. I use the code: file = StringIO.StringIO(data) im = Image.open(file) im.show() where data is datafrom a blob in a db. This code is working outside Zope, but at once when i try to make it a product in Zope, I get this error: IOError: cannot identify image file I've had problems using PIL-based products in Zope because Zope has its own module called "ImageFile" and Zope does some sys.path munging so that when certain PIL modules do "import ImageFile", they import the Zope version, instead of the ImageFile.py that comes with PIL. This causes lots of hard-to-track errors that have "weird" error messages ( I always get "BadFont" ). I have "fixed" this problem before by editing the module for the type of image I am using to do a more explicit import. For example, for JPEG images, I edit PIL/JpegImagePlugin.py to read: from PIL import ImageFile This is at or around line 34, which reads "import ImageFile". So, you could make the changes to the files corresponding to the Image type you are using, then *restart Zope* (the fix is in site-packages so a Refresh won't do it!) and then give it a try. I'd be happy to hear if this helps you, John Ziniti ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Zope 2.7.0 and Pythom Image Library
John Ziniti wrote at 2004-7-6 20:44 -0400: > ... >I've had problems using PIL-based products in Zope because Zope >has its own module called "ImageFile" and Zope does some sys.path >munging so that when certain PIL modules do "import ImageFile", >they import the Zope version, instead of the ImageFile.py that >comes with PIL. This causes lots of hard-to-track errors that >have "weird" error messages ( I always get "BadFont" ). I do not think this is a Zope fault... We can use Zope and PIL together without any problem and without the need to change either Zope nor PIL. >I have "fixed" this problem before by editing the module for >the type of image I am using to do a more explicit import. For >example, for JPEG images, I edit PIL/JpegImagePlugin.py to >read: > >from PIL import ImageFile Provided that "PIL.JpegImagePlugin" was imported via the "PIL" package, "import ImageFile" will work as well -- without any danger to clash with any other "ImageFile"... The problem almost surely is that PIL provides for accessing PIL modules without going through the PIL package *AND* your application makes use of this possibility. Always access PIL modules in your application code via "PIL.module" and never via "module". -- Dieter ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )