[Image-SIG] NameError using ImageOps.equalize, with patch.

Christian Hudon chrish@debian.org
Thu, 20 Jun 2002 10:47:04 -0500


Hi,

I can't have been the first person to hit this, but I had a quick look in
the mailing list archive for the months after the PIL 1.1.3 release and
didn't see anything, so here it goes:

ImageOps.equalize fails with a "NameError: global name 'operator is not
defined" exception. 

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\Python22\Lib\site-packages\PIL\ImageOps.py", line 143, in
  equalize
    step = reduce(operator.add, h[b:b+256]) / 255
NameError: global name 'operator' is not defined

The obvious patch (appended to this email) fixes the
problem.

  Christian

--- ImageOps.py~        2002-04-23 12:10:56.000000000 -0400
+++ ImageOps.py 2002-06-20 11:21:24.000000000 -0400
@@ -15,7 +15,7 @@
 # See the README file for information on usage and redistribution.
 #

-import Image
+import Image, operator

 #
 # helpers