Giter VIP home page Giter VIP logo

nickel-chrome's Introduction

nickel-chrome

Install

yarn global add nickel-chrome

if you are patient, you can also install it with npm:

npm i -g nickel-chrome

Usage

Launch the nickel-chrome server

nickel-chrome

You can specify number of workers (default: 5):

nickel-chrome 3

You can change the default port (default: 3010):

NICKEL_CHROME_PORT=4242 nickel-chrome

You 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

nickel-chrome's People

Contributors

iryusa avatar meriadec avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.