Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the name for screenshot.png with headless chrome screenshots?

I'm using this command for screenshots:

chromium-browser --headless --screenshot https://www.google.com

From here.

This basically works:

[1101/145557.285618:ERROR:gpu_process_transport_factory.cc(980)] Lost UI shared context.
[1101/145558.357174:INFO:headless_shell.cc(538)] Written to file screenshot.png.

(It's well covered elsewhere, but I haven't found a useful fix for the Lost UI error. This is not relevant.)

How can I set the name of screenshot.png to be saved as something else?

I found a couple of rundowns of chrome command line switches, such as this one, but the most likely looking flag, "--output" was not relevant to screenshots.

If you have a better recommendation for headless or chromeless screenshots, that is as simple as this, I'm all ears.

like image 773
Mittenchops Avatar asked Dec 18 '22 20:12

Mittenchops


1 Answers

--screenshot=filename.png.

Reference: https://cs.chromium.org/search/?q=symbol:kDefaultScreenshotFileName

Similarly, --print-to-pdf also accepts a filename.

like image 73
Josh Lee Avatar answered Feb 16 '23 04:02

Josh Lee