PIL+Zope: what's wrong with this code ?
Hi, I plan to use PIL in an external method to retrieve Images from de ZODB and transform them to PIL Images. When I use the following code I've got an error which basically says: "Not enough image data" This seems to be a PIL error, not a Zope's one, but I really can't understand what the problem is, except that I don't know what mode parameter to pass to fromstring(), I've tried "1", "P", "RGB" etc... but without luck: --- CUT --- import PIL.Image # get the logo GIF Image from the ZODB # This object exists and is OK when viewed from the ZMI logo = getattr(self, "logo") imgdata = logo.data if type(imgdata) is not type('') : temp = '' while imgdata is not None : temp = temp + imgdata.data imgdata = imgdata.next imgdata = temp MyPILImage = PIL.Image.fromstring("1", (logo.width, logo.height), imgdata) --- CUT --- I'm really not sure about the two first parameters that the PIL.Image.fromstring() function need, the first one is the mode, the second is the size. Could someone with a PIL+Zope experience show me a code snippet to convert Zope Image objects (in any format) to PIL Images ? Thanks in advance. PS: I use Zope 2.3.2 and PIL 1.1.1 Jerome Alet - alet@unice.fr - http://cortex.unice.fr/~jerome Fac de Medecine de Nice http://wwwmed.unice.fr Tel: (+33) 4 93 37 76 30 Fax: (+33) 4 93 53 15 15 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE
Did you know that there's a Zope Product called Photo that uses PIL? Download that and look into the source. Peter ----- Original Message ----- From: "Jerome Alet" <alet@unice.fr> To: <zope@zope.org> Sent: Friday, June 01, 2001 11:46 AM Subject: [Zope] PIL+Zope: what's wrong with this code ?
Hi,
I plan to use PIL in an external method to retrieve Images from de ZODB and transform them to PIL Images.
When I use the following code I've got an error which basically says:
"Not enough image data"
This seems to be a PIL error, not a Zope's one, but I really can't understand what the problem is, except that I don't know what mode parameter to pass to fromstring(), I've tried "1", "P", "RGB" etc... but without luck:
--- CUT --- import PIL.Image
# get the logo GIF Image from the ZODB # This object exists and is OK when viewed from the ZMI logo = getattr(self, "logo") imgdata = logo.data if type(imgdata) is not type('') : temp = '' while imgdata is not None : temp = temp + imgdata.data imgdata = imgdata.next imgdata = temp MyPILImage = PIL.Image.fromstring("1", (logo.width, logo.height), imgdata) --- CUT ---
I'm really not sure about the two first parameters that the PIL.Image.fromstring() function need, the first one is the mode, the second is the size.
Could someone with a PIL+Zope experience show me a code snippet to convert Zope Image objects (in any format) to PIL Images ?
Thanks in advance.
PS: I use Zope 2.3.2 and PIL 1.1.1
Jerome Alet - alet@unice.fr - http://cortex.unice.fr/~jerome Fac de Medecine de Nice http://wwwmed.unice.fr Tel: (+33) 4 93 37 76 30 Fax: (+33) 4 93 53 15 15 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Fri, 1 Jun 2001, Peter Bengtsson wrote:
Did you know that there's a Zope Product called Photo that uses PIL? Download that and look into the source.
Thanks but it works now and I've got no time to dig in the code yet. bye, Jerome Alet
participants (2)
-
Jerome Alet -
Peter Bengtsson