no point creating two images

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

@ -312,11 +312,16 @@ class model(dict):
return None
def get_screenshot_as_jpeg(self):
# Created by save_screenshot()
fname = os.path.join(self.watch_data_dir, "last-screenshot.jpg")
fname = os.path.join(self.watch_data_dir, "last-screenshot.png")
if os.path.isfile(fname):
return fname
import io
# Make a JPEG that's used in notifications (due to being a smaller size) available
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)))
return img_byte_arr.getvalue()
# False is not an option for AppRise, must be type None
return None

@ -360,11 +360,6 @@ class ChangeDetectionStore:
f.write(screenshot)
f.close()
# Make a JPEG that's used in notifications (due to being a smaller size) available
from PIL import Image
im1 = Image.open(target_path)
im1.convert('RGB').save(target_path.replace('.png','.jpg'), quality=int(os.getenv("NOTIFICATION_SCREENSHOT_JPG_QUALITY", 75)))
def save_error_text(self, watch_uuid, contents):
if not self.data['watching'].get(watch_uuid):

@ -81,8 +81,9 @@ def test_check_notification(client, live_server):
datastore = 'test-datastore'
with open(os.path.join(datastore, str(uuid), 'last-screenshot.png'), 'wb') as f:
f.write(base64.b64decode(testimage_png))
with open(os.path.join(datastore, str(uuid), 'last-screenshot.jpg'), 'wb') as f:
f.write(base64.b64decode(testimage_jpg))
# We no longer create two images
# with open(os.path.join(datastore, str(uuid), 'last-screenshot.jpg'), 'wb') as f:
# f.write(base64.b64decode(testimage_jpg))
# Goto the edit page, add our ignore text
# Add our URL to the import page

Loading…
Cancel
Save