[Zope-dev] Zope 2.7.0 and Pythom Image Library
John Ziniti
jziniti at speakeasy.org
Tue Jul 6 20:44:40 EDT 2004
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
More information about the Zope-Dev
mailing list