chromedp 包中的 FullScreenshot() 生成的屏幕截图太模糊,我该如何改进?

chromedp 包中的 fullscreenshot() 生成的屏幕截图太模糊,我该如何改进?

php小编柚子有一个关于chromedp包的问题需要解答。问题是关于使用FullScreenshot()生成的屏幕截图太模糊,需要改进的方法。在使用chromedp包时,生成的屏幕截图质量可能不如预期,这可能是由于一些配置或参数设置不正确导致的。下面将介绍一些可能的改进方法,帮助你得到更清晰的屏幕截图。

问题内容

如标题所示,这是结果和我的代码。顺便说一句,我用的是一台非常低端的机器。

func main() { chromectx, _ := chromedp.newcontext(context.background()) emulation.setdevicemetricsoverride(1920, 1080, 1.0, false).do(chromectx) var width, height int64 var b []byte err := chromedp.run(chromectx, chromedp.emulateviewport(10, 10), chromedp.navigate(`the content of the file is in the code block below.html`), chromedp.evaluateasdevtools(`document.documentelement.scrollwidth`, &width), chromedp.emulateviewport(width, 10), chromedp.evaluateasdevtools(`document.documentelement.scrollheight`, &height), chromedp.emulateviewport(width, height), chromedp.fullscreenshot(&b, 100), ) if err != nil { log.fatal(err) } err = ioutil.writefile("test.png", b, 0777) if err != nil { log.fatal(err) } } 登录后复制