Playwright screenshots - no need for high-res "bug workaround" screenshot, use lower quality/faster configurable image quality env var

pull/697/head
dgtlmoon 3 years ago
parent 4841c79b4c
commit 4a91505af5

@ -356,9 +356,15 @@ class base_html_playwright(Fetcher):
# Bug 3 in Playwright screenshot handling # Bug 3 in Playwright screenshot handling
# Some bug where it gives the wrong screenshot size, but making a request with the clip set first seems to solve it # Some bug where it gives the wrong screenshot size, but making a request with the clip set first seems to solve it
# JPEG is better here because the screenshots can be very very large # JPEG is better here because the screenshots can be very very large
# Screenshots also travel via the ws:// (websocket) meaning that the binary data is base64 encoded
# which will significantly increase the IO size between the server and client, it's recommended to use the lowest
# acceptable screenshot quality here
try: try:
page.screenshot(type='jpeg', clip={'x': 1.0, 'y': 1.0, 'width': 1280, 'height': 1024}) # Quality set to 1 because it's not used, just used as a work-around for a bug, no need to change this.
self.screenshot = page.screenshot(type='jpeg', full_page=True, quality=92) 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)))
except Exception as e: except Exception as e:
context.close() context.close()
browser.close() browser.close()

Loading…
Cancel
Save