4

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!

PaulOlteanu
  • 43
  • 1
  • 4

1 Answers1

4

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())

mata
  • 67,110
  • 10
  • 163
  • 162