PIL question about crop method

Gary Herron gherron at islandtraining.com
Wed Apr 5 15:05:01 EDT 2006


John Salerno wrote:

>I might be way off target even looking into this method for what I need 
>to do, but I'm still a little confused about the description of it:
>
>crop
>im.crop(box) => image
>
>Returns a rectangular region from the current image. The box is a 
>4-tuple defining the left, upper, right, and lower pixel coordinate.
>
>I'm probably just being a little dense again, but how exactly do you 
>write the tuple? Wouldn't a coordinates parameter be a tuple of tuples? 
>It sounds like here you only need four numbers, but I don't understand 
>what 'left, upper, right, and lower pixel coordinate' means. It doesn't 
>seem like it's asking for a set of coordinates for each corner of the 
>box, or for a set at all. How do four separate numbers make up coordinates?
>
>Thanks.
>  
>
If you want the cropped rectangle to go from 100 to 200 in x and 300 to 
400 in y, then those four values need to be placed in a tuple in the 
specified order:
  box=(100,300,200,400)

Gary Herron




More information about the Python-list mailing list