Skip to content

Instantly share code, notes, and snippets.

@themorgantown
Last active April 10, 2018 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themorgantown/dce6ee55e9ff7fd3a9c0e9bfbffd45b0 to your computer and use it in GitHub Desktop.
Save themorgantown/dce6ee55e9ff7fd3a9c0e9bfbffd45b0 to your computer and use it in GitHub Desktop.
This simple package takes a local or live URL on the web and generates screenshots.
// Optional delay, JPG or PNG To run, place these two files in a folder, and run `npm install` within the folder then node index.js to run this example file after including your own local or remote URLs. To get the 'file:///' URL, open a html in Safari.
const Pageres = require('pageres');
// Learn more about Pageres here: https://github.com/sindresorhus/pageres
const pageres = new Pageres({delay: 1, filename: 'Default', format: 'png'})
// Load a file from URL and take a series of screenshots. Note that you need to remove the 'filename' above
// to create multiple formats.
//.src('https://tumult.com/hype/gallery/BootSale/BootSale.html', ['728x90', '1024x768', 'iphone 5s'], {crop: true})
// Take a screenshot of a local file
.src('file:///Users/daniel/pagerestest/input/728x90.html', ['728x90'], {crop: true})
// Other examples included in package:
//.src('todomvc.com', ['1280x1024', '1920x1080'])
//.src('data:text/html;base64,PGgxPkZPTzwvaDE+', ['1024x768'])
.dest(__dirname)
.run()
.then(() => console.log('done'));
{
"name": "screenshotbuilder",
"version": "1.0.0",
"description": "Generates screenshots from Webpages",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"pageres": "^4.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment