[Zope] PIL not working in Zope

Tom Cameron tom@mooball.com
Thu, 26 Jul 2001 13:20:12 +1000


have spent some time now trying to get PIL to work in Zope.

When I call it in python it works fine and I seem to be able to use all
functions without trouble. But from Zope I get all sorts of errors. I am
trying to resize an image to a thumbnail. I started by writing my own code
and after no success I finally found the code on this page
http://www.zope.org/Members/michel/ZB/ScriptingZope.html it looked almost
identical to mine, but I tried it to be sure and I still get the same
errors.

What I have noticed is this:

If I use the code exactly as is, I get the following error:

	Error Type: TypeError
	Error Value: expected string, ImplicitAcquirerWrapper found

	<!--
	Traceback (innermost last):
	  File /usr/local/Zope/2-3-0/lib/python/ZPublisher/Publish.py, line 223, in
publish_module
	  File /usr/local/Zope/2-3-0/lib/python/ZPublisher/Publish.py, line 187, in
publish
	  File /usr/local/Zope/2-3-0/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
	    (Object: Traversable)
	  File /usr/local/Zope/2-3-0/lib/python/ZPublisher/Publish.py, line 171, in
publish
	  File /usr/local/Zope/Zope-2.3.0-src/lib/python/ZPublisher/mapply.py, line
160, in mapply
	    (Object: index_html)
	  File /usr/local/Zope/2-3-0/lib/python/ZPublisher/Publish.py, line 112, in
call_object
	    (Object: index_html)
	  File /usr/local/Zope/Zope-2.3.0-src/lib/python/OFS/DTMLDocument.py, line
189, in __call__
	    (Object: index_html)
	  File
/usr/local/Zope/Zope-2.3.0-src/lib/python/DocumentTemplate/DT_String.py,
line 538, in __call__
	    (Object: index_html)
	  File
/usr/local/Zope/Zope-2.3.0-src/lib/python/DocumentTemplate/DT_Util.py, line
334, in eval
	    (Object: thumbnail('Iceberg.jpg',size=160))
	    (Info: thumbnail)
	  File &lt;string&gt;, line 0, in ?
	  File
/usr/local/Zope/Zope-2.3.0-src/lib/python/Products/ExternalMethod/ExternalMe
thod.py, line 269, in __call__
	    (Object: thumbnail)
	    (Info: (('Iceberg.jpg',), {'size': 160}, (128,)))
	  File /usr/local/Zope/2-3-0/Extensions/ImageFunctions.py, line 19, in
makeThumbnail
	    (Object: Traversable)
	TypeError: (see above)

	-->

If I change the 'cStringIO' over to 'StringIO' I get the following error:

	Error Type: IOError
	Error Value: image file is truncated, 7 bytes left in buffer
	<!--
	Traceback (innermost last):
	  File /usr/local/Zope/2-3-0/lib/python/ZPublisher/Publish.py, line 223, in
publish_module
	  File /usr/local/Zope/2-3-0/lib/python/ZPublisher/Publish.py, line 187, in
publish
	  File /usr/local/Zope/2-3-0/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
	    (Object: Traversable)
	  File /usr/local/Zope/2-3-0/lib/python/ZPublisher/Publish.py, line 171, in
publish
	  File /usr/local/Zope/Zope-2.3.0-src/lib/python/ZPublisher/mapply.py, line
160, in mapply
	    (Object: index_html)
	  File /usr/local/Zope/2-3-0/lib/python/ZPublisher/Publish.py, line 112, in
call_object
	    (Object: index_html)
	  File /usr/local/Zope/Zope-2.3.0-src/lib/python/OFS/DTMLDocument.py, line
189, in __call__
	    (Object: index_html)
	  File
/usr/local/Zope/Zope-2.3.0-src/lib/python/DocumentTemplate/DT_String.py,
line 538, in __call__
	    (Object: index_html)
	  File
/usr/local/Zope/Zope-2.3.0-src/lib/python/DocumentTemplate/DT_Util.py, line
334, in eval
	    (Object: thumbnail('Iceberg.jpg',size=160))
	    (Info: thumbnail)
	  File &lt;string&gt;, line 0, in ?
	  File
/usr/local/Zope/Zope-2.3.0-src/lib/python/Products/ExternalMethod/ExternalMe
thod.py, line 269, in __call__
	    (Object: thumbnail)
	    (Info: (('Iceberg.jpg',), {'size': 160}, (128,)))
	  File /usr/local/Zope/2-3-0/Extensions/ImageFunctions.py, line 21, in
makeThumbnail
	    (Object: Traversable)
	  File /usr/local/lib/python1.5/site-packages/PIL/Image.py, line 427, in
convert
	  File /usr/local/lib/python1.5/site-packages/PIL/ImageFile.py, line 152,
in load
	IOError: (see above)

	-->

With more testing I have found that the error occures  on the line:
  image=image.convert('RGB')

I can open the image, I can also query its size and format, but the moment I
try to manipulate the image these errors occur.

Any hints would be appreciated.

Zope 2.3.3 on Python1.5.2 on FreeBSD 4.0

Tom