Skip to content
Snippets Groups Projects
Commit 225abb17 authored by Jonas Kjærandsen's avatar Jonas Kjærandsen
Browse files

Screenshots now in 1280x960 resolution

parent f5da0b2e
No related branches found
No related tags found
1 merge request!2Merge react-branch into main.
......@@ -85,7 +85,10 @@ func ScreenshotURL(url string, Response *ResultFrontendResponse) {
//////
// capture entire browser viewport, returning png with quality=90
if err := chromedp.Run(ctx, fullScreenshot(SearchURL, 90, &screenshotbuf)); err != nil {
/*if err := chromedp.Run(ctx, fullScreenshot(SearchURL, 90, &screenshotbuf)); err != nil {
log.Fatal(err)
}*/
if err := chromedp.Run(ctx, screenScreenshot(SearchURL, &screenshotbuf)); err != nil {
log.Fatal(err)
}
/*
......@@ -97,6 +100,16 @@ func ScreenshotURL(url string, Response *ResultFrontendResponse) {
Response.Screenshot = screenshotbuf
}
// Inspired by the emulation example at https://github.com/chromedp/examples/blob/master/emulate/main.go
// elementScreenshot takes a screenshot of a specific element.
func screenScreenshot(urlstr string, res *[]byte) chromedp.Tasks {
return chromedp.Tasks{
chromedp.EmulateViewport(1280, 960),
chromedp.Navigate(urlstr),
chromedp.CaptureScreenshot(res),
}
}
// fullScreenshot takes a screenshot of the entire browser viewport.
//
// Note: chromedp.FullScreenshot overrides the device's emulation settings. Use
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment