From 953ebe4951403b0c7ff91a5e385b3c26842f5c35 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 12 Nov 2022 12:38:08 -0800 Subject: [PATCH] Add imagetools.save_to_bytes. --- voussoirkit/imagetools.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/voussoirkit/imagetools.py b/voussoirkit/imagetools.py index cbd8996..efa3c66 100644 --- a/voussoirkit/imagetools.py +++ b/voussoirkit/imagetools.py @@ -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