Add convert

dont-create-jpg-copy-of-png
dgtlmoon 2 years ago
parent 9f6dc6cd04
commit 8e5ea2cc93

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

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

Loading…
Cancel
Save