[Image-SIG] PIL 1.1.5 "stub" discovered

Fredrik Lundh fredrik at pythonware.com
Tue Nov 8 13:05:12 CET 2005


Christoph Rackwitz wrote:

>I was trying to .point() an "F"-type Image and got a traceback. A
> little digging around revealed this:
>
>>>> import Image
>>>> im = Image.new("F", (100, 100))
>>>> im = im.point(lambda v: v)
> Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>  File "C:\python\Lib\site-packages\PIL\Image.py", line 1035, in point
>    scale, offset = _getscaleoffset(lut)
>  File "C:\python\Lib\site-packages\PIL\Image.py", line 360, in _getscaleoffset
>    (a, b, c) = data # simplified syntax
> ValueError: need more than 1 value to unpack
>>>> def dump(v, w):
> ...     print repr(v); return w
> ...
>>>> im.point(lambda v: dump(v.data, v))
> ['stub']
> Traceback (most recent call last):...
>
> I just wanted to hand you back your reminder ;)

when used on floating point images, the point method requires a callable object
that applies the following expression on its argument:

      argument * scale + offset

the point method evaluates this expression once, using a special stub object that
builds an expression descriptor.  the method then uses a fast linear point transform
on the image.  your example shows that the stub object doesn't handle unsupported
expression forms, but that's not very surprising ;-)

</F> 





More information about the Image-SIG mailing list