Capture screenshots of websites on command line or REST API.
$ snapkit https://google.com --emulate="iPad" | open -a Preview.app -f
Or, from inside your own Node.js program.
const snapkit = require('snapkit')
async () => {
let image = await snapkit('https://google.com')
}
/* snapkit has a child process that starts on import, close it */
async close => snapkit.close()
Accepts either HTML page content as as string or a URL to a remote site.
options
<[Object]>emulate
<[string]> Device to emulate, list of available devices atsnapkit.devices
transparency
<[boolean]> Hides default white background and allows capturing screenshots with transparency. Defaults tofalse
.userAgent
<[string]>type
<[string]> Specify screenshot type, can be eitherjpeg
orpng
. Defaults to 'png'.quality
<[number]> The quality of the image, between 0-100. Not applicable topng
images.fullPage
<[boolean]> When true, takes a screenshot of the full scrollable page. Defaults tofalse
.viewport
<[Object]>width
<[number]> page width in pixels.height
<[number]> page height in pixels.deviceScaleFactor
<[number]> Specify device scale factor (can be thought of as dpr). Defaults to1
.isMobile
<[boolean]> Whether themeta viewport
tag is taken into account. Defaults tofalse
.hasTouch
<[boolean]> Specifies if viewport supports touch events. Defaults tofalse
isLandscape
<[boolean]> Specifies if viewport is in landscape mode. Defaults tofalse
.
clip
<[Object]> An object which specifies clipping region of the page. Should have the following fields:x
<[number]> x-coordinate of top-left corner of clip areay
<[number]> y-coordinate of top-left corner of clip areawidth
<[number]> width of clipping areaheight
<[number]> height of clipping area
Array of available device emulations.
Close the browser instance and child process.