PIL, Python and CGI
Sascha Ferley
Sascha.Ferley at infineon.net
Sun Jun 23 15:52:29 EDT 2002
Hi,
I have a problem when writing a program of mine and moving it into a CGI
based form.
Basically if i run the python program in shell mode, it works fine. But
when i run it via cgi mode
it screws up horobly.
The problem is, I am using the function from the PIL library as follows.
import sys
import cgi
import Image
from urllib import urlretrieve
form = cgi.FieldStorage()
inputPath = form["inpP"].value
compPath = form["secP"].value
try:
im1 = urlretrieve(inputPath)[0]
im2 = urlretrieve(compPath)[0]
print im1
print im2
except:
print "Error occured in grabbing files!"
sys.exit(1)
try:
Image1 = Image.open(im1) # Tried
Image.open(im1).histogram() still gives error
Image2 = Image.open(im2)
except:
print "Error opening files"
sys.exit(1)
print image1.histogram()
print image2.histogram()
Looking at the error-log i see just following:
Traceback (most recent call last):
File "/export/server/web/cgi-bin/compare.py", line 29, in ?
print image1.histogram()
File "/usr/local/lib/python2.2/site-packages/PIL/Image.py", line 577,
in histo
gram
self.load()
File "/usr/local/lib/python2.2/site-packages/PIL/ImageFile.py", line
126, in l
oad
self.load_prepare()
File "/usr/local/lib/python2.2/site-packages/PIL/ImageFile.py", line
180, in l
oad_prepare
self.im = Image.core.new(self.mode, self.size)
File "/usr/local/lib/python2.2/site-packages/PIL/Image.py", line 39,
in __geta
ttr__
raise ImportError, "The _imaging C module is not installed"
ImportError: The _imaging C module is not installed
Anyone have any ideas?
Sascha
More information about the Python-list
mailing list