See sharp's instructions for installing libvips. Sharp is used to resize screenshots and turn them into JPEG, PNG or WebP images.
After that a simple
npm install grabber should do the trick.
ChromeDriver is straight-forward to install via npm install, but if you want to
use Firefox to take screenshots you'll have to be running Selenium server.
Try out some of these guides for getting Xvfb and Selenium running so that you can take "headless" screenshots in a Linux environment. You probably don't want to be screenshotting in OSX or Windows or a real (non-framebuffer) X server because the browser window is going to pop up.
Both Firefox and Chrome seem to have the limitation that you can't resize the browser window to be larger than the screen, so you're limited by your screen dimensions. In Linux you can probably get around this to some extent using Xvfb.
Chrome cannot take a screenshot of the full page and will only screenshot the visible portion. Firefox can screenshot the entire page, but this library doesn't allow for that just yet.
grabber = require 'grabber'chromeOptions =hostname: "127.0.0.1"port: 9515pathname: "/wd/hub"args:"--url-base=/wd/hub""--port=" + 9515"--verbose"browser = grabberchromeinitchromeOptionsreturn consoleerrorerr if errscreenshotOptions =url: ''width: 1024height: 768resize: 512quality: 80# see browser.waitForConditionInBrowser in wdcondition: "document.querySelectorAll('.foo').length > 0"# see wd for documentation on browser:# Do something with browser like dismiss popups or scroll down to the# button of the page or whatever you want to do before you take a# screenshot.cb # remember to call cb() when you're done# save the fileout: 'google.jpg'grabbercommandsscreenshot browserscreenshotOptionsreturn consoleerrorerr if err# image now contains an instance of a sharp image object thing that you can# then do something with if you want. Probably not necesary if you passed# in an out parameter
Most of the action happens in the examples/ directory.
chrome_screenshot.coffee and firefox_screenshot.coffee are command-line utilities to take screenshots.
The parameters are url, width, height, resize, quality, crop. The CLI utilities also take an --out=filename.(png|jpeg|webp) parameter and support a -t parameter for testing with Thing's settings.