我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用PIL.Image.SAVE。
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