From e622774c0f56cb17c4f256e6d8895e12800f76bb Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sun, 11 Jul 2021 22:31:37 +1000 Subject: [PATCH] made GenThumb return thumb and orig_w, orig_h - not sure this stays, but for optimising it prob. will -- its not being used in pa_job_mgr yet, and that will see the final version of this --- shared.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/shared.py b/shared.py index d3499f3..0e36a04 100644 --- a/shared.py +++ b/shared.py @@ -88,22 +88,23 @@ def GenThumb(fname): bands = im.getbands() if 'A' in bands: im = im.convert('RGB') + orig_w, orig_h = im.size im.thumbnail((THUMBSIZE,THUMBSIZE)) img_bytearray = io.BytesIO() im.save(img_bytearray, format='JPEG') img_bytearray = img_bytearray.getvalue() thumbnail = base64.b64encode(img_bytearray) thumbnail = str(thumbnail)[2:-1] - return thumbnail + return thumbnail, orig_w, orig_h except Exception as e: print( f"GenThumb failed: {e}") - return None + return None, None, None def GenFace(fname): img = face_recognition.load_image_file(fname) location = face_recognition.face_locations(img) encodings = face_recognition.face_encodings(img, known_face_locations=location) if len(encodings): - return encodings[0].tobytes() + return encodings[0].tobytes(), location else: - return None + return None, None