[Image-SIG] PIL 1.1.6 eval function

Dennis Shimer dshimer at gmail.com
Thu Jan 11 17:12:53 CET 2007


How about if you
im=Image.open('red.jpg','r')

which will give you open jpeg object then

Image.eval(im,function).show()

or if you want to do it all on one line

Image.eval(Image.open('red.jpg','r'),function).show()

Dennis

On 1/11/07, Cochran, Travis <Travis.Cochran at analog.com> wrote:
> I tried  that and got this error.
>
>
> Traceback (most recent call last):
>   File "C:\Documents and Settings\tcochra\My Documents\test", line 6, in
> -toplevel-
>     Image.eval("red.jpg",function).show()
>   File "C:\Python24\Lib\site-packages\PIL\Image.py", line 1979, in eval
>     return image.point(args[0])
> AttributeError: 'str' object has no attribute 'point'
>
>
>
> Could it be a problem with the IJG JEPG library? I reinstalled PIL and
> still get the error. Thanks for you help.
>
> -Travis Cochran
>
> -----Original Message-----
> From: Dennis Shimer [mailto:dshimer at gmail.com]
> Sent: Thursday, January 11, 2007 10:43 AM
> To: Cochran, Travis
> Subject: Re: [Image-SIG] PIL 1.1.6 eval function
>
> This worked for me.
>
> open an image object, I'll call im
>
> Write a function that you would like applied to each pixel of im, here
> is a dumb one that will just double the value this making the new image
> very very bright.
>
> def function(pixel):
>     return pixel*2
>
> Then eval the image based on the function
>
> Image.eval(im2,function).show()
>
> or save it to a new image which you can save
>
> newimage=Image.eval(im2,function)
>
> Dennis Shimer
>
>
> On 1/11/07, Cochran, Travis <Travis.Cochran at analog.com> wrote:
> > I'm trying to use the Image.eval function on a JPEG image. I can't
> > seem to find the right syntax for entering the function and it gives
> > me errors for the variables I try to use, "R,G,B". Any idea what I'm
> > doing wrong?
> > -Travis Cochran
> > _______________________________________________
> > Image-SIG maillist  -  Image-SIG at python.org
> > http://mail.python.org/mailman/listinfo/image-sig
> >
>


More information about the Image-SIG mailing list