postcards_folder.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:postcards 作者: abertschi 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号