installing PIF in win32 zope
I am a newbie working through the zope book and tutorials. The zope book examples regarding Image manipulation states that the python PIF is required. The only info I can find for installing PIF is Unix/Linux oriented.. I am using the zope binary, and my config (as copied from control panel) is: Zope Version (Zope 2.7.4-0, python 2.3.4, win32) Python Version 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] System Platform win32 SOFTWARE_HOME C:\Program Files\Zope-2.7.4-0\lib\python ZOPE_HOME C:\Program Files\Zope-2.7.4-0 INSTANCE_HOME C:\Zope-Instance CLIENT_HOME C:\Zope-Instance\var is PIF included already? (in which case the exapmles failed) and if not, how do I install it into the existing zope?? I do not have a separate python installation, just the one with zope. I have the win32 install for PIF (1.1.4) but it complains about not finding a python installed in the registry, and fails. lil' help please? Ian No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.5 - Release Date: 03/02/2005
Ian Hood wrote:
I am a newbie working through the zope book and tutorials. The zope book examples regarding Image manipulation states that the python PIF is required.
I suppose you want PIL == Python Image Library instead of PIF! http://www.pythonware.com/products/pil/ I do not know about any PIF in Zope/Python context.
The only info I can find for installing PIF is Unix/Linux oriented..
I believe it'll be easier for a newbie to use PIL modules from Zope ExternalMethods. - Install PIL in Windows from binaries (site mentioned above). - Just create a file in <Zope install path>\Extensions, and inside ZMI (Zope Management Interface) create a ExternalMethod object that maps to a function inside the prior file. The file that contains the function bound to the ExternalMethod inside Zope could look like the following example: <myfile.py> import os from StringIO import StringIO from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageChops # to insert Images inside Zope from OFS.Image import manage_addImage def make_label(label, fontname, fontsize, fg=(0,0,0), bg=(0,0,0), transp=10): """Return StringIO object with a image that represents a transparent label""" font = ImageFont.truetype(fontname ,fontsize) Img=Image.new("L", (10,10),0) color_list = [] for c in bg+fg: color_list.append(c) Img.putpalette(color_list) draw = ImageDraw.Draw(Img) sizex, sizey = draw.textsize(label,font=font) Img = Img.resize((sizex,sizey)) draw = ImageDraw.Draw(Img) bimsize = (sizex, sizey) width,height = bimsize xoff = yoff = 0 draw.text((xoff,yoff), label, fill=1, font=font) imgfile = StringIO() Img.save(imgfile,'png', transparency=transp) imgfile.seek(0,0) del Img return imgfile def zope_make_label(self, oid, label, fontname, fontsize, fg, bg, transp): imgfile = make_label(label, fontname, fontsize, fg, bg, transp) manage_addImage(self, oid, imgfile) del imgfile </myfile.py> best regards, Senra -- Rodrigo Senra MSc Computer Engineer rodsenra@gpr.com.br GPr Sistemas Ltda http://www.gpr.com.br
Hi Ian,
I believe it'll be easier for a newbie to use PIL modules from Zope ExternalMethods.
- Install PIL in Windows from binaries (site mentioned above).
- Just create a file in <Zope install path>\Extensions, and inside ZMI (Zope Management Interface) create a ExternalMethod object that maps to a function inside the prior file. Yes, that's right. However, if you are using a zope binary, you will you will have also need either to install a python 2.3.x binary (*), install PIL, then move it to the zope's python libraries, or fake the windows registry (**) to tell where to install PIL.
(*) The PIL binary looks for the python installed on the system and because zope doesn't register the python binary it uses, you have to do this step. To see what files you have to copy and where, see the following reference. (**) Here on this page is a registry file, which you will have to modify on a text editor in order to reflect the python version of zope (replace "2.1" for "2.3", for Zope 2.7): http://www.zope.org/Members/SmileyChris/howto/pil_for_windows Please read carefully the contents of that web page. It is a little bit outdated because it was made for Zope 2.5.1, so, if you want to use 2.7.x, then instead of copying the pil.pth file and the PIL folder into: folderYourZopeFolder/lib/python, you have to copy it into: folderYourZopeFolder/bin/Lib/site-packages. Regards, Josef
Rodrigo Dias Arruda Senra wrote:
Ian Hood wrote:
I am a newbie working through the zope book and tutorials. The zope book examples regarding Image manipulation states that the python PIF is required.
I suppose you want PIL == Python Image Library instead of PIF! http://www.pythonware.com/products/pil/
I do not know about any PIF in Zope/Python context.
The only info I can find for installing PIF is Unix/Linux oriented..
I believe it'll be easier for a newbie to use PIL modules from Zope ExternalMethods.
- Install PIL in Windows from binaries (site mentioned above).
- Just create a file in <Zope install path>\Extensions, and inside ZMI (Zope Management Interface) create a ExternalMethod object that maps to a function inside the prior file.
The file that contains the function bound to the ExternalMethod inside Zope could look like the following example:
<myfile.py> import os from StringIO import StringIO from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageChops # to insert Images inside Zope from OFS.Image import manage_addImage
def make_label(label, fontname, fontsize, fg=(0,0,0), bg=(0,0,0), transp=10): """Return StringIO object with a image that represents a transparent label""" font = ImageFont.truetype(fontname ,fontsize) Img=Image.new("L", (10,10),0) color_list = [] for c in bg+fg: color_list.append(c) Img.putpalette(color_list) draw = ImageDraw.Draw(Img) sizex, sizey = draw.textsize(label,font=font) Img = Img.resize((sizex,sizey)) draw = ImageDraw.Draw(Img) bimsize = (sizex, sizey) width,height = bimsize xoff = yoff = 0 draw.text((xoff,yoff), label, fill=1, font=font) imgfile = StringIO() Img.save(imgfile,'png', transparency=transp) imgfile.seek(0,0) del Img return imgfile
def zope_make_label(self, oid, label, fontname, fontsize, fg, bg, transp): imgfile = make_label(label, fontname, fontsize, fg, bg, transp) manage_addImage(self, oid, imgfile) del imgfile </myfile.py>
best regards, Senra
Yes, actually, I did mean PIL 8^s My main problem has been the step: - Install PIL in Windows from binaries (site mentioned above). which the PIL binary will not do because the installer says it can not find a python in the win registry, (apparently the python installed with the zope binaries is not 'registered' with windows by zope). The installer does not allow path override (nor would i know where to put it). I can use winzip to unpack the .exe but I have no idea what goes where (and whether it would work) Winzip shows 71 files, mostly .py with a few .pyd with a destination path of platlib/pil/ but I don't know where to extract it to. thanks Ian -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.5 - Release Date: 03/02/2005
Hi Ian,
My main problem has been the step: - Install PIL in Windows from binaries (site mentioned above). which the PIL binary will not do because the installer says it can not find a python in the win registry, (apparently the python installed with the zope binaries is not 'registered' with windows by zope). The installer does not allow path override (nor would i know where to put it). See my earlier reply on this thread. There I said exactly what you're saying here. You have to install python or fake the windows registry to be able to install PIL. (See my reply for details on how to do it)
I can use winzip to unpack the .exe but I have no idea what goes where (and whether it would work) Winzip shows 71 files, mostly .py with a few .pyd with a destination path of platlib/pil/ but I don't know where to extract it to. Why are you trying to unpack it with winzip? Just double clicking on it will install PIL.
Regards, Josef
participants (3)
-
Ian Hood -
Josef Meile -
Rodrigo Dias Arruda Senra