kopia lustrzana https://github.com/dgtlmoon/changedetection.io
Re #1148 - Notification screenshot/JPEG was not being regenerated correctly
rodzic
68d5178367
commit
ade9e1138b
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Ładowanie…
Reference in New Issue