[Zope] installing PIF in win32 zope
Ian Hood
NoSolicitors at shaw.ca
Fri Feb 4 14:00:59 EST 2005
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
More information about the Zope
mailing list