[Image-SIG] crop question

Jason Van Anden jason at smileproject.com
Tue Feb 13 18:48:47 CET 2007


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
error:

"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)
        tim.save("test.tif")

Advice super appreciated!

Thank You ~ j


More information about the Image-SIG mailing list