[Tutor] Questions about PIL

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Thu Nov 9 00:30:05 CET 2006



On Wed, 8 Nov 2006, Chris Hengge wrote:

> I'm trying to figure out how to compare im1 to im2 and recognize the
> difference. I dont care what the difference is...
>
> something like
>
> if im1 is not im2:
>    print "Not same"

Do not use 'is' here.  It is not doing any kind of equality testing at 
all.  We had a discussion about 'is' just a few days ago:

     http://mail.python.org/pipermail/tutor/2006-November/050680.html

According to:

     http://www.pythonware.com/library/pil/handbook/image.htm

the im.getdata() function looks interesting.


> I've tried im.tostring() but that doesn't ever enter the loop either.

This should have worked.  I'm not sure if you tried comparing 
two strings using 'is' or not.

> Second question is this:
> Is there a way to divide the screen so I only grab maybe the lower right
> 200x200 pixels or some such?
> Or possibly a way to seperate the image into a grid so I could just take the
> grid I wanted?

im.transform() from the documentation link above looks relevant.  Is that 
what you're looking for?


More information about the Tutor mailing list