Python PIL.Image 模块,SAVE 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用PIL.Image.SAVE

项目:eoj3    作者:ultmaster    | 项目源码 | 文件源码
def get_bytes(self, format='PNG'):
        '''
        usage:  i = Identicon('xx')
                print(i.base64())
        return: this image's base64 code
        created by: liuzheng712
        bug report: https://github.com/liuzheng712/identicons/issues
        '''
        self.calculate()
        fp = io.BytesIO()
        self.image.encoderinfo = {}
        self.image.encoderconfig = ()

        if format.upper() not in Image.SAVE:
            Image.init()
        save_handler = Image.SAVE[format.upper()]
        try:
            save_handler(self.image, fp, '')
        finally:
            fp.seek(0)
            return fp