Add convert

This commit is contained in:
dgtlmoon
2023-03-18 20:07:33 +01:00
parent 9f6dc6cd04
commit 8e5ea2cc93
2 changed files with 2 additions and 1 deletions

View File

@@ -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

View File

@@ -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'