From 7cc6952d830dc38bd4ffd7c70de384808cede6d3 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Fri, 16 Jan 2026 10:10:09 +0100 Subject: [PATCH] Hack fix for selenium 3 --- .../content_fetchers/webdriver_selenium.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/changedetectionio/content_fetchers/webdriver_selenium.py b/changedetectionio/content_fetchers/webdriver_selenium.py index eebf10579..0ce08b234 100644 --- a/changedetectionio/content_fetchers/webdriver_selenium.py +++ b/changedetectionio/content_fetchers/webdriver_selenium.py @@ -157,7 +157,17 @@ class fetcher(Fetcher): import io img = Image.open(io.BytesIO(screenshot_png)) # Convert to RGB if needed (JPEG doesn't support transparency) - if img.mode != 'RGB': + # Always convert non-RGB modes to RGB to ensure JPEG compatibility + if img.mode in ('RGBA', 'LA', 'P', 'PA'): + # Handle transparency by compositing onto white background + if img.mode == 'P': + img = img.convert('RGBA') + background = Image.new('RGB', img.size, (255, 255, 255)) + if img.mode in ('RGBA', 'LA', 'PA'): + background.paste(img, mask=img.split()[-1]) # Use alpha channel as mask + img = background + elif img.mode != 'RGB': + # For other modes, direct conversion img = img.convert('RGB') jpeg_buffer = io.BytesIO() img.save(jpeg_buffer, format='JPEG', quality=int(os.getenv("SCREENSHOT_QUALITY", 72)))