Numerous Pulsating Martians
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

snapkit

1.0.3 • Public • Published

snapkit

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()

snapkit(url||content[, options])

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 at snapkit.devices
    • transparency <[boolean]> Hides default white background and allows capturing screenshots with transparency. Defaults to false.
    • userAgent <[string]>
    • type <[string]> Specify screenshot type, can be either jpeg or png. Defaults to 'png'.
    • quality <[number]> The quality of the image, between 0-100. Not applicable to png images.
    • fullPage <[boolean]> When true, takes a screenshot of the full scrollable page. Defaults to false.
    • 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 to 1.
      • isMobile <[boolean]> Whether the meta viewport tag is taken into account. Defaults to false.
      • hasTouch<[boolean]> Specifies if viewport supports touch events. Defaults to false
      • isLandscape <[boolean]> Specifies if viewport is in landscape mode. Defaults to false.
    • 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 area
      • y <[number]> y-coordinate of top-left corner of clip area
      • width <[number]> width of clipping area
      • height <[number]> height of clipping area

snapkit.devices

Array of available device emulations.

snapkit.close()

Close the browser instance and child process.

Keywords

none

install

npm i snapkit

Downloadsweekly downloads

5

version

1.0.3

license

Apache-2.0

repository

githubgithub

last publish

collaborators

  • avatar