feat: Improve screenshot quality by increasing device pixel ratio
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
bb99648822
commit
4ec35ab9f9
@ -127,9 +127,14 @@ class ImageGenerator:
|
||||
body_width = await page.evaluate('document.body.offsetWidth')
|
||||
await page.set_viewport_size({"width": body_width, "height": body_height})
|
||||
|
||||
# 设置更高的设备像素比以获得更清晰的图像
|
||||
await page.evaluate('''() => {
|
||||
window.devicePixelRatio = 2;
|
||||
}''')
|
||||
|
||||
# 截图
|
||||
image_path = f"match_report_{match_data.get('match_id')}.png"
|
||||
await page.screenshot(path=image_path, full_page=True)
|
||||
await page.screenshot(path=image_path, full_page=True, quality=100)
|
||||
await browser.close()
|
||||
|
||||
# 上传图片
|
||||
@ -210,9 +215,14 @@ class ImageGenerator:
|
||||
body_width = await page.evaluate('document.body.offsetWidth')
|
||||
await page.set_viewport_size({"width": body_width, "height": body_height})
|
||||
|
||||
# 设置更高的设备像素比以获得更清晰的图像
|
||||
await page.evaluate('''() => {
|
||||
window.devicePixelRatio = 2;
|
||||
}''')
|
||||
|
||||
# 截图
|
||||
image_path = f"recent_matches_{player_name.replace(' ', '_')}_{datetime.datetime.now().strftime('%Y%m%d%H%M%S')}.png"
|
||||
await page.screenshot(path=image_path, full_page=True)
|
||||
await page.screenshot(path=image_path, full_page=True, quality=100)
|
||||
await browser.close()
|
||||
|
||||
# 上传图片
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user