Add imagetools.save_to_bytes.

This commit is contained in:
voussoir 2022-11-12 12:38:08 -08:00
parent 5695450289
commit 953ebe4951

View file

@ -210,3 +210,10 @@ def rotate_by_exif(image):
exif[ORIENTATION_KEY] = 1
return (image, exif)
def save_to_bytes(image, *save_args, **save_kwargs):
bio = io.BytesIO()
image.save(bio, *save_args, **save_kwargs)
bio.seek(0)
blob = bio.read()
return blob