send as jpeg to save data

This commit is contained in:
Ruben van de Ven 2019-02-08 21:18:49 +01:00
parent 97679edde0
commit 059f67e736
1 changed files with 7 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import thread
from websocket import create_connection
import logging
import json
from io import BytesIO
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('portraits')
@ -78,10 +79,15 @@ def updateStats(type, name, count, image_filename):
# only send every one in x image, so that the server never can
# retrace _exact_ faces by comparing the sent frames.
with open(image_filename) as fp:
im = Image.open(fp)
bytesImg = BytesIO()
im.save(bytesImg, format='jpeg')
bytesImg.seek(0)
logger.info('send request including image')
r = requests.post(
url ,
files={'image': fp},
files={'image': bytesImg},
params=params
)
else: