Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 Pillow Image 对象图像,我尝试使用它保存到一个名为 temp 的 IO.BytesIO 对象image.save(temp, format="jpg")
image.save(temp, format="jpg")
但是,当我运行它时,它会在此行给出 KeyError: "JPG"save_handler = SAVE[format.upper()]
save_handler = SAVE[format.upper()]
谢谢!
格式称为jpeg,而不是jpg,所以只需使用:
jpeg
jpg
image.save(temp, format="jpeg")
请参阅图像文件格式以获取可能值的参考(或PIL.Image.SAVE.keys())
PIL.Image.SAVE.keys()