I'm running Firefox on a Xvfb in a VPS. What I want to do is to take a full page screenshot of the page.
I can redirect Firefox to particular page using
firefox http://google.com
and take a screenshot (inside X) using ImageMagick
import root -window output.jpg
The problem is, most of the page need scrolling and I can't know the height beforehand.
The other way is to pick a very big height (like 4000px) and then process the image and remove the useless part. But that's unnecessary processing.
I found many Firefox add-ons, but I'm looking for a solution that can be programmed using the Shell Command line.
Edit: I ended up writing my own FireFox extension for doing this.
This question is related to
shell
firefox
command-line
screenshot
Firefox Screenshots is a new tool that ships with Firefox. It is not a developer tool, it is aimed at end-users of the browser.
To take a screenshot, click on the page actions menu in the address bar, and click "take a screenshot". If you then click "Save full page", it will save the full page, scrolling for you.
(source: mozilla.net)
You can use selenium and the webdriver for Firefox.
import selenium.webdriver
import selenium.common
options = selenium.webdriver.firefox.options.Options()
# options.headless = True
with selenium.webdriver.Firefox(options=options) as driver:
driver.get('http://google.com')
time.sleep(2)
root=driver.find_element_by_tag_name('html')
root.screenshot('whole page screenshot.png')
I think what you are looking for is a utility which enables you to save a complete page opened in your browser into a png file. Most probably you are looking for a utility like commandlineprint2.
After installing the extension, you just need to type the command:
firefox -print http://google.com -printfile ~/foo.png
Update 2018-07-23
As was just pointed out in the comments, this question was about getting a screenshot from the command line. Sorry, I just read over that. So here is the correct answer:
As of Firefox 57 you can create a screenshot in headless mode like this:
firefox -screenshot https://developer.mozilla.com
Read more in the documentation.
Update 2017-06-15
As of Firefox 55 there is Firefox Screenshots as a more flexible alternative. As of Firefox 57 Screenshots can capture a full page, too.
Original answer
Since Firefox 32 there is also a full page screenshot button in the developer tools (F12). If it is not enabled go to the developer tools settings (gear button) and choose "Take a fullpage screenshot" at the "Available Toolbox Buttons" section.
source: developer.mozilla.org
By default the screenshots are saved in the download directory. This works similar to screenshot --fullpage
in the toolbar.
I ended up coding a custom solution (Firefox extension) that does this. I think by the time I developed it, the commandline mentioned in enreas wasn't there.
The Firefox extension is CmdShots. It's a good option if you need finer degree of control over the process of taking the screenshot (or you want to do some HTML/JS modifications and image processing).
You can use it and abuse it. I decided to keep it unlicensed, so you are free to play with it as you want.
Source: Stackoverflow.com