I have a Pillow Image object image, that I try to save to an IO.BytesIO object called temp using image.save(temp, format="jpg")
When I run this however, it gives a KeyError: "JPG" on this line save_handler = SAVE[format.upper()]
Thanks!
The format is called jpeg
, not jpg
, so just use:
image.save(temp, format="jpeg")
See Image file formats for reference of possible values (or PIL.Image.SAVE.keys()
)