From 059f67e73685d5d2bd8bbbc7111b082fe15f82ed Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Fri, 8 Feb 2019 21:18:49 +0100 Subject: [PATCH] send as jpeg to save data --- portrait_compositor.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/portrait_compositor.py b/portrait_compositor.py index 8995886..1ea0e65 100644 --- a/portrait_compositor.py +++ b/portrait_compositor.py @@ -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: