From 8e5ea2cc93a848175d85823c763db387be944b46 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Sat, 18 Mar 2023 20:07:33 +0100 Subject: [PATCH] Add convert --- changedetectionio/model/Watch.py | 2 +- changedetectionio/tests/test_notification.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/changedetectionio/model/Watch.py b/changedetectionio/model/Watch.py index 45ff3f52..f6cf8f3b 100644 --- a/changedetectionio/model/Watch.py +++ b/changedetectionio/model/Watch.py @@ -320,7 +320,7 @@ class model(dict): from PIL import Image im = Image.open(fname) img_byte_arr = io.BytesIO() - im.save(img_byte_arr, format='JPEG', quality=int(os.getenv("NOTIFICATION_SCREENSHOT_JPG_QUALITY", 75))) + im.convert('RGB').save(img_byte_arr, format='JPEG', quality=int(os.getenv("NOTIFICATION_SCREENSHOT_JPG_QUALITY", 75))) return img_byte_arr.getvalue() # False is not an option for AppRise, must be type None diff --git a/changedetectionio/tests/test_notification.py b/changedetectionio/tests/test_notification.py index cce3e877..9564fcd2 100644 --- a/changedetectionio/tests/test_notification.py +++ b/changedetectionio/tests/test_notification.py @@ -163,6 +163,7 @@ def test_check_notification(client, live_server): # Check the attachment was added, and that it is a JPEG from the original PNG notification_submission_object = json.loads(notification_submission) + # We actually convert the PNG to JPEG and send it assert notification_submission_object['attachments'][0]['filename'] == 'last-screenshot.jpg' assert len(notification_submission_object['attachments'][0]['base64']) assert notification_submission_object['attachments'][0]['mimetype'] == 'image/jpeg'