diff --git a/changedetectionio/content_fetchers/playwright.py b/changedetectionio/content_fetchers/playwright.py index 4002fbbf1..6c5256b42 100644 --- a/changedetectionio/content_fetchers/playwright.py +++ b/changedetectionio/content_fetchers/playwright.py @@ -49,6 +49,9 @@ async def capture_full_page_async(page, screenshot_format='JPEG', watch_uuid=Non if page_height > page.viewport_size['height']: if page_height < step_size: step_size = page_height # Incase page is bigger than default viewport but smaller than proposed step size + # Never set viewport taller than our max capture height - otherwise one screenshot chunk + # captures the whole (e.g. 8098px) page even when SCREENSHOT_MAX_HEIGHT=1000 + step_size = min(step_size, SCREENSHOT_MAX_TOTAL_HEIGHT) viewport_start = time.time() logger.debug(f"{watch_info}Setting bigger viewport to step through large page width W{page.viewport_size['width']}xH{step_size} because page_height > viewport_size") # Set viewport to a larger size to capture more content at once diff --git a/changedetectionio/content_fetchers/screenshot_handler.py b/changedetectionio/content_fetchers/screenshot_handler.py index fb09f9aeb..6451f269b 100644 --- a/changedetectionio/content_fetchers/screenshot_handler.py +++ b/changedetectionio/content_fetchers/screenshot_handler.py @@ -56,6 +56,10 @@ def stitch_images_worker_raw_bytes(pipe_conn, original_page_height, capture_heig im.close() del images + # Clip stitched image to capture_height (chunks may overshoot by up to step_size-1 px) + if total_height > capture_height: + stitched = stitched.crop((0, 0, max_width, capture_height)) + # Draw caption only if page was trimmed if original_page_height > capture_height: draw = ImageDraw.Draw(stitched)