def slice_image(self, source_image, tile_width, tile_height):
if not os.path.isfile(source_image):
self.logger.error('file {} does not exist'.format(source_image))
exit(1)
file = open(source_image, 'rb')
with Image.open(file) as image:
cwd = os.getcwd()
basename = strftime("slice_%Y-%m-%d_%H-%M-%S", gmtime())
directory = os.path.join(cwd, basename)
self.logger.info('slicing picture {} into tiles'.format(source_image))
tiles = make_tiles(image, tile_width=tile_width, tile_height=tile_height)
store_tiles(tiles, directory)
self.logger.info('picture sliced into {} tiles {}'.format(len(tiles), directory))
评论列表
文章目录