All pastes #2076096 Raw Edit

Stuff

public text v1 · immutable
#2076096 ·published 2011-06-07 10:35 UTC
rendered paste body
import sys
from vipsCC import *

tilesize = 20

try:
    im = VImage.VImage (sys.argv[1])

    # loop to create the tiles
    for y in range (0, im.Ysize(), tilesize):
        for x in range (0, im.Xsize(), tilesize):
            filename = 'x_%d_y_%d.jpg' % (x / tilesize, y / tilesize)
            # clip tilesize against image size
            width = min (im.Xsize () - x, tilesize)
            height = min (im.Ysize () - y, tilesize)
            im.extract_area (x, y, width, height).write (filename)

except VError.VError, e:
    e.perror (sys.argv[0])