diff --git a/changedetectionio/model/Watch.py b/changedetectionio/model/Watch.py index 62eaf33b..0b94aa65 100644 --- a/changedetectionio/model/Watch.py +++ b/changedetectionio/model/Watch.py @@ -252,20 +252,11 @@ class model(dict): return None def get_screenshot_as_jpeg(self): - """Best used in notifications due to its smaller size""" - png_fname = os.path.join(self.watch_data_dir, "last-screenshot.png") - jpg_fname = os.path.join(self.watch_data_dir, "last-screenshot.jpg") - - if os.path.isfile(jpg_fname): - return jpg_fname - - if os.path.isfile(png_fname) and not os.path.isfile(jpg_fname): - # Doesnt exist, so create the JPEG from the PNG - from PIL import Image - im1 = Image.open(png_fname) - im1.convert('RGB').save(jpg_fname, quality=int(os.getenv("NOTIFICATION_SCREENSHOT_JPG_QUALITY", 75))) - return jpg_fname + # Created by save_screenshot() + fname = os.path.join(self.watch_data_dir, "last-screenshot.jpg") + if os.path.isfile(fname): + return fname # False is not an option for AppRise, must be type None return None diff --git a/changedetectionio/store.py b/changedetectionio/store.py index 04d4fb39..adfba663 100644 --- a/changedetectionio/store.py +++ b/changedetectionio/store.py @@ -368,6 +368,12 @@ 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): return