|
@@ -32,10 +32,14 @@ def gen_tiles(image, output_path, min_scale=0, max_scale=8, crop_x=256, crop_y=2
|
|
|
geom = (x, y, min(im.size[0], x + crop_x),
|
|
|
min(im.size[1], y + crop_y))
|
|
|
dest = os.path.join(output_path,
|
|
|
- "{:03}-{:03}-{:03}.jpg".format(scale,
|
|
|
- x // crop_x,
|
|
|
- y // crop_y))
|
|
|
- im.crop(geom).save(dest)
|
|
|
+ "{}-{}-{}.jpg".format(-scale,
|
|
|
+ x // crop_x,
|
|
|
+ y // crop_y))
|
|
|
+ tile = im.crop(geom)
|
|
|
+ if x + crop_x > im.size[0] or y + crop_y > im.size[1]:
|
|
|
+ # The tile is smaller than 256x256, so fill the rest with black
|
|
|
+ tile = im.transform((crop_x, crop_y), PIL.Image.AFFINE, (1, 0, x, 0, 1, y))
|
|
|
+ tile.save(dest)
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|