mirror of https://github.com/tenox7/wrp.git
add delay/sleep flag
This commit is contained in:
parent
6de3fad580
commit
0128b3ff8e
18
README.md
18
README.md
|
@ -50,16 +50,18 @@ Or from the [Azure Console](https://portal.azure.com/#create/Microsoft.Container
|
||||||
|
|
||||||
Fortunately ACI allows port 80 without encryption.
|
Fortunately ACI allows port 80 without encryption.
|
||||||
|
|
||||||
|
|
||||||
## Flags
|
## Flags
|
||||||
|
|
||||||
```
|
```text
|
||||||
-l listen address:port (default :8080)
|
-l listen address:port (default :8080)
|
||||||
-t image type gif or png (default gif)
|
-t image type gif or png (default gif)
|
||||||
-g image geometry, WxHxC, height can be 0 for unlimited (default 1152x600x256)
|
-g image geometry, WxHxC, height can be 0 for unlimited (default 1152x600x216)
|
||||||
-h headless mode, hide browser window on the server (default true)
|
C (number of colors) is only used for GIF
|
||||||
-d chromedp debug logging (default false)
|
-h headless mode, hide browser window on the server (default true)
|
||||||
-n do not free maps and gif images after use (default false)
|
-d chromedp debug logging (default false)
|
||||||
|
-n do not free maps and gif images after use (default false)
|
||||||
|
-ui html template file (default "wrp.html")
|
||||||
|
-s delay/sleep after page is rendered before screenshot is taken (default 2s)
|
||||||
```
|
```
|
||||||
|
|
||||||
## UI explanation
|
## UI explanation
|
||||||
|
|
4
wrp.go
4
wrp.go
|
@ -50,6 +50,7 @@ var (
|
||||||
defType string
|
defType string
|
||||||
defGeom geom
|
defGeom geom
|
||||||
htmlTmpl *template.Template
|
htmlTmpl *template.Template
|
||||||
|
delay time.Duration
|
||||||
)
|
)
|
||||||
|
|
||||||
// go:embed *.html
|
// go:embed *.html
|
||||||
|
@ -306,7 +307,7 @@ func (rq *wrpReq) capture() {
|
||||||
}
|
}
|
||||||
chromedp.Run(
|
chromedp.Run(
|
||||||
ctx, emulation.SetDeviceMetricsOverride(int64(float64(rq.width)/rq.zoom), height, rq.zoom, false),
|
ctx, emulation.SetDeviceMetricsOverride(int64(float64(rq.width)/rq.zoom), height, rq.zoom, false),
|
||||||
chromedp.Sleep(time.Second*2), // TODO(tenox): totally lame, find a better way to determine if page is rendered
|
chromedp.Sleep(delay), // TODO(tenox): find a better way to determine if page is rendered
|
||||||
)
|
)
|
||||||
// Capture screenshot...
|
// Capture screenshot...
|
||||||
err = chromedp.Run(ctx, chromedpCaptureScreenshot(&pngcap, rq.height))
|
err = chromedp.Run(ctx, chromedpCaptureScreenshot(&pngcap, rq.height))
|
||||||
|
@ -496,6 +497,7 @@ func main() {
|
||||||
flag.StringVar(&defType, "t", "gif", "Image type: gif|png")
|
flag.StringVar(&defType, "t", "gif", "Image type: gif|png")
|
||||||
flag.StringVar(&fgeom, "g", "1152x600x216", "Geometry: width x height x colors, height can be 0 for unlimited")
|
flag.StringVar(&fgeom, "g", "1152x600x216", "Geometry: width x height x colors, height can be 0 for unlimited")
|
||||||
flag.StringVar(&tHTML, "ui", "wrp.html", "HTML template file for the UI")
|
flag.StringVar(&tHTML, "ui", "wrp.html", "HTML template file for the UI")
|
||||||
|
flag.DurationVar(&delay, "s", 2*time.Second, "Delay/sleep after page is rendered and before screenshot is taken")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if len(os.Getenv("PORT")) > 0 {
|
if len(os.Getenv("PORT")) > 0 {
|
||||||
addr = ":" + os.Getenv(("PORT"))
|
addr = ":" + os.Getenv(("PORT"))
|
||||||
|
|
Loading…
Reference in New Issue