我有一个 Pillow Image 对象图像,我尝试使用 image.save(temp, format="jpg") 将其保存到名为 temp 的 IO.BytesIO 对象
但是,当我运行此命令时,它会在这一行给出 KeyError: "JPG"save_handler = SAVE[format.upper()]
谢谢!
最佳答案
该格式称为jpeg
,而不是jpg
,因此只需使用:
image.save(temp, format="jpeg")
参见Image file formats引用可能的值(或PIL.Image.SAVE.keys()
)
关于python - 枕头保存到 BytesIO 或 StringIO KeyError : "JPG",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37791782/