diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index 060df7acc..f4714c1be 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -642,20 +642,23 @@ def changedetection_app(config=None, datastore_o=None): enabled_tabs.append('visual-selector') enabled_tabs.append('text-filters-and-triggers') + if watch.get('fetch_processor') == 'image': + enabled_tabs.append('visual-selector') + output = render_template("edit.html", - uuid=uuid, - watch=watch, - form=form, - enabled_tabs = enabled_tabs, - has_empty_checktime=using_default_check_time, - has_default_notification_urls=True if len(datastore.data['settings']['application']['notification_urls']) else False, - using_global_webdriver_wait=default['webdriver_delay'] is None, current_base_url=datastore.data['settings']['application']['base_url'], emailprefix=os.getenv('NOTIFICATION_MAIL_BUTTON_PREFIX', False), + enabled_tabs = enabled_tabs, + form=form, + has_default_notification_urls=True if len(datastore.data['settings']['application']['notification_urls']) else False, + has_empty_checktime=using_default_check_time, + playwright_enabled=os.getenv('PLAYWRIGHT_DRIVER_URL', False), settings_application=datastore.data['settings']['application'], + using_global_webdriver_wait=default['webdriver_delay'] is None, + uuid=uuid, visualselector_data_is_ready=visualselector_data_is_ready, visualselector_enabled=visualselector_enabled, - playwright_enabled=os.getenv('PLAYWRIGHT_DRIVER_URL', False) + watch=watch, ) return output @@ -809,6 +812,8 @@ def changedetection_app(config=None, datastore_o=None): previous_version = dates[-2] + datastore.set_last_viewed(uuid, time.time()) + output = render_template("diff-image.html", watch=watch, extra_stylesheets=extra_stylesheets, @@ -1074,7 +1079,13 @@ def changedetection_app(config=None, datastore_o=None): new_img = watch.history[watch.newest_history_key] prev_img = watch.history[compare_date] - img = image_diff.render_diff(new_img, prev_img) + try: + img = image_diff.render_diff(new_img, prev_img) + except ValueError as e: + print ("EXCEPTION: Diff image - got exception {} reverting to raw image without rendering difference".format(str(e))) + with open(new_img, 'rb') as f: + img = f.read() + resp = make_response(img) resp.headers['Content-Type'] = 'image/jpeg' @@ -1243,7 +1254,7 @@ def changedetection_app(config=None, datastore_o=None): extras['fetch_processor']=fetch_processor if fetch_processor == 'image': extras['fetch_backend'] = 'html_webdriver' - + new_uuid = datastore.add_watch(url=url, tag=request.form.get('tag').strip(), extras=extras diff --git a/changedetectionio/content_fetcher.py b/changedetectionio/content_fetcher.py index d1c38074c..d077081a5 100644 --- a/changedetectionio/content_fetcher.py +++ b/changedetectionio/content_fetcher.py @@ -421,9 +421,9 @@ class base_html_playwright(Fetcher): # acceptable screenshot quality here try: # Quality set to 1 because it's not used, just used as a work-around for a bug, no need to change this. - page.screenshot(type='jpeg', clip={'x': 1.0, 'y': 1.0, 'width': 1280, 'height': 1024}, quality=1) + #page.screenshot(type='jpeg', clip={'x': 1.0, 'y': 1.0, 'width': 1280, 'height': 1024}, quality=1) # The actual screenshot - self.screenshot = page.screenshot(type='jpeg', full_page=True, quality=int(os.getenv("PLAYWRIGHT_SCREENSHOT_QUALITY", 72))) + self.screenshot = page.screenshot(type='jpeg', full_page=True, quality=int(os.getenv("PLAYWRIGHT_SCREENSHOT_QUALITY", 82))) except Exception as e: context.close() browser.close() diff --git a/changedetectionio/fetch_processor/image.py b/changedetectionio/fetch_processor/image.py index 8f1f1472a..e4dbd1b7d 100644 --- a/changedetectionio/fetch_processor/image.py +++ b/changedetectionio/fetch_processor/image.py @@ -89,8 +89,13 @@ class perform_site_check(fetch_processor): if 'image' in fetcher.headers['content-type']: self.contents = fetcher.raw_content else: + # should be element if the filter is set, no? self.contents = fetcher.screenshot + # Used for visual-selector + self.xpath_data = fetcher.xpath_data + self.screenshot = fetcher.screenshot + image = Image.open(io.BytesIO(self.contents)) # @todo different choice? diff --git a/changedetectionio/image_diff.py b/changedetectionio/image_diff.py index 1f0333275..77ecb494f 100644 --- a/changedetectionio/image_diff.py +++ b/changedetectionio/image_diff.py @@ -33,8 +33,8 @@ def render_diff(fpath_imageA, fpath_imageB): # bounding box on both input images to represent where the two # images differ (x, y, w, h) = cv2.boundingRect(c) - cv2.rectangle(imageA, (x, y), (x + w, y + h), (0, 0, 255), 2) - cv2.rectangle(imageB, (x, y), (x + w, y + h), (0, 0, 255), 2) + cv2.rectangle(imageA, (x, y), (x + w, y + h), (0, 0, 255), 1) + cv2.rectangle(imageB, (x, y), (x + w, y + h), (0, 0, 255), 1) #return cv2.imencode('.jpg', imageB)[1].tobytes() return cv2.imencode('.jpg', imageA)[1].tobytes() diff --git a/changedetectionio/static/images/picture-frame.svg b/changedetectionio/static/images/picture-frame.svg new file mode 100644 index 000000000..994de57e3 --- /dev/null +++ b/changedetectionio/static/images/picture-frame.svg @@ -0,0 +1,149 @@ + + + + diff --git a/changedetectionio/static/styles/styles.css b/changedetectionio/static/styles/styles.css index 9835c9b0f..9376569a3 100644 --- a/changedetectionio/static/styles/styles.css +++ b/changedetectionio/static/styles/styles.css @@ -578,3 +578,15 @@ ul { display: inline; height: 26px; vertical-align: middle; } + +#quickwatch-fetch-processor { + color: #fff; + font-size: 80%; } + #quickwatch-fetch-processor ul { + padding: 0px; + list-style-type: none; } + #quickwatch-fetch-processor ul li { + display: inline-block; + margin-right: 1em; } + #quickwatch-fetch-processor ul li label:hover { + cursor: pointer; } diff --git a/changedetectionio/static/styles/styles.scss b/changedetectionio/static/styles/styles.scss index e8b4a6ab8..0f5338abb 100644 --- a/changedetectionio/static/styles/styles.scss +++ b/changedetectionio/static/styles/styles.scss @@ -803,4 +803,24 @@ ul { padding: 0.5rem; border-radius: 5px; color: #ff3300; -} \ No newline at end of file +} + +#quickwatch-fetch-processor { + color: #fff; + font-size: 80%; + + ul { + padding: 0px; + list-style-type: none; + li { + display: inline-block; + margin-right: 1em; + label { + &:hover { + cursor: pointer; + } + } + } + } +} + diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html index 64f0c5ffd..95d59cfa5 100644 --- a/changedetectionio/templates/edit.html +++ b/changedetectionio/templates/edit.html @@ -28,9 +28,7 @@ {% if 'visual-selector' in enabled_tabs %}