ImageFilter failing for mode = 1

Christian Hanemann CHanemann at cch.com.au
Tue Jan 29 18:43:54 EST 2008


Hello,

 

I'm trying to sharpen some JPEGs after resizing and am being given a
valueError as per the below:

 

  File "getGraphicDetails.py", line 32, in main

    enhancer = ImageEnhance.Sharpness(img)

  File "/usr/local/lib/python2.3/site-packages/PIL/ImageEnhance.py",
line 89, in __init__

    self.degenerate = image.filter(ImageFilter.SMOOTH)

  File "/usr/local/lib/python2.3/site-packages/PIL/Image.py", line 786,
in filter

    return self._new(filter.filter(self.im))

  File "/usr/local/lib/python2.3/site-packages/PIL/ImageFilter.py", line
55, in filter

    return apply(image.filter, self.filterargs)

ValueError: image has wrong mode

 

Does anyone know if I'm just using an old version of PIL and this has
subsequently been addressed or if I'm using it incorrectly.  It appears
to die on the line:

 

enhancer = ImageEnhance.Sharpness(img)

 

If I put in an:

 

If img.mode = "1":

   enhancer = ImageEnhance.Sharpness(img.convert("L"))

 

it works fine, but I was wondering if the library should or does work
without having to convert.

 

Thankyou

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080130/d28f5379/attachment.html>


More information about the Python-list mailing list