I'm trying to save a picture into a buffer. For that I'm using the following code:
import io
from PIL import Image
buffer = io.StringIO()
img = Image.open(<image_path>)
img = img.resize((640,960), Image.NEAREST)
format = "JPG" # JPG,PNG,etc.
img.save(buffer,format)
However, I get KeyError: 'JPG'
. I've seen several answers using this approach, so I don't know why I'm getting this error. Here's an example.