[Image-SIG] crop question
ken at seehart.com
Tue Feb 13 23:12:26 CET 2007
Jason Van Anden wrote:
> I am trying to take an existing image and split it into equally sized
> tiles. When I try to save a "cropped" image I get the following
> "tile cannot extend outside image"
> The first pass saves the first tile correctly, the second one chokes
> and blurts the error.
> Following is some code to illustrate my confusion:
> original_image = Image.open("big_image.tif")
> # math stuff
> w, h = orig.size
> self.tile_width = w = w/self.tiles_across
> self.tile_height = h = h/self.tiles_down
> for y in range (self.tiles_down):
> for x in range (self.tiles_across):
> box = (x * w, y * h, w, h)
> tim = original_image.crop(box)
> Advice super appreciated!
> Thank You ~ j
Crop uses right and lower instead of width and height for the last two
elements of the box.
*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.
More information about the Image-SIG