1.6.2 • Published 8 years ago
nickel-chrome v1.6.2
nickel-chrome
Install
yarn global add nickel-chromeif you are patient, you can also install it with npm:
npm i -g nickel-chromeUsage
Launch the nickel-chrome server
nickel-chromeYou can specify number of workers (default: 5):
nickel-chrome 3You can change the default port (default: 3010):
NICKEL_CHROME_PORT=4242 nickel-chromeYou can also do nothing and nothing will happen.
Create screenshots
The server will handle POST requests on /, with a payload looking like this:
{
"html": "<div>hello world</div>",
}This is the only required property. Let's see what other options you have.
Options
{
// the HTML to screenshot
html: '',
// specify page size
viewportSize: {
width: 650,
height: 650,
// the screenshot will be taken full page height
fullPage: false,
},
// resize final image
resize: {
width: 300,
// if not given, will resize conserving ratio
height: 150,
}
// inject custom styles in page. the keys are querySelectors. the values
// will be merged to CSSStyleDeclaration of the found node
styles: {
body: {
marginTop: 40,
},
'.my-class': {
backgroundColor: 'red',
}
},
// capture the given element (can't be used with `fullPage`)
selector: '.my-element',
// wait for 'load' event on the page, until this max timeout
loadTimeout: 300,
}the response format will be a base64-encoded image.
License
BSD-2-Clause