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
This commit is contained in:
@@ -88,22 +88,23 @@ def GenThumb(fname):
|
|||||||
bands = im.getbands()
|
bands = im.getbands()
|
||||||
if 'A' in bands:
|
if 'A' in bands:
|
||||||
im = im.convert('RGB')
|
im = im.convert('RGB')
|
||||||
|
orig_w, orig_h = im.size
|
||||||
im.thumbnail((THUMBSIZE,THUMBSIZE))
|
im.thumbnail((THUMBSIZE,THUMBSIZE))
|
||||||
img_bytearray = io.BytesIO()
|
img_bytearray = io.BytesIO()
|
||||||
im.save(img_bytearray, format='JPEG')
|
im.save(img_bytearray, format='JPEG')
|
||||||
img_bytearray = img_bytearray.getvalue()
|
img_bytearray = img_bytearray.getvalue()
|
||||||
thumbnail = base64.b64encode(img_bytearray)
|
thumbnail = base64.b64encode(img_bytearray)
|
||||||
thumbnail = str(thumbnail)[2:-1]
|
thumbnail = str(thumbnail)[2:-1]
|
||||||
return thumbnail
|
return thumbnail, orig_w, orig_h
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print( f"GenThumb failed: {e}")
|
print( f"GenThumb failed: {e}")
|
||||||
return None
|
return None, None, None
|
||||||
|
|
||||||
def GenFace(fname):
|
def GenFace(fname):
|
||||||
img = face_recognition.load_image_file(fname)
|
img = face_recognition.load_image_file(fname)
|
||||||
location = face_recognition.face_locations(img)
|
location = face_recognition.face_locations(img)
|
||||||
encodings = face_recognition.face_encodings(img, known_face_locations=location)
|
encodings = face_recognition.face_encodings(img, known_face_locations=location)
|
||||||
if len(encodings):
|
if len(encodings):
|
||||||
return encodings[0].tobytes()
|
return encodings[0].tobytes(), location
|
||||||
else:
|
else:
|
||||||
return None
|
return None, None
|
||||||
|
|||||||
Reference in New Issue
Block a user