GithubHelp home page GithubHelp logo

capture-1's Introduction

Capture - Simple screenshot tool using PhantomJS Build Status

Capture, as it's name implies, will capture a screenshot of one or more URL's using PhantomJS. The format of the screenshot can be anything supported by Phantom, such as PNG, GIF, JPG, or PDF.

Capture is a Node.js based library that can be used as a module within another application, or as a stand alone tool via it's command line interface (CLI).

Install

To install capture you must first have Node.js, NPM and PhantomJS installed, all of which is outside the scope of these instructions. Please see the Node.js Website for details on how to install Node and NPM. Personaly I am found of Tim Caswell's excelent NVM tool for insalling and managing Node. Homebrew is also an excelent tool for installing PhantomJS, Node or NPM on a Mac.

Once NPM is installed, simply install Capture by executing the following from the command line:

npm install capture -g

Command Line Usage

Once installed, you can explore what capture can do by simply typing capture into the command line. You will get the built in help that looks something like this:

Capture screenshots of URLs.
Usage: node ./index.js [url1 url2 ...]

Options:
  --verbose, -v              Verbose logging                                     [boolean]
  --out, -o                  Output directory for captured screenshots           [string]
  --format, -f               Output image format (png, jpg, gif, pdf)            [string]  [default: "png"]
  --phantomjs, -P            Path to phantomjs bin                               [string]
  --username, -u             HTTP Basic Auth Username                            [string]
  --password, -p             HTTP Basic Auth Password                            [string]
  --viewport-width, --vw     Minimum viewport width                              [string]  [default: 1024]
  --viewport-height, --vh    Minimum viewport height                             [string]  [default: 768]
  --paper-format, --pf       Size of the individual PDF pages (A4, letter)       [string]  [default: "A4"]
  --paper-orientation, --po  Orientation of the PDF pages (portrait, landscape)  [string]  [default: "portrait"]
  --paper-margin, --pm       Margin of the PDF pages (2cm, 5mm, etc.)            [string]  [default: "2.5mm"]
  --help, -h                 Show this help message and exit                     [boolean]

Executing capture http://your-domain.com/ http://your-domain.com/about/ will create a directory in the current working directory with the following structure:

your-domain-com/
	index.png
	about/
		index.png

Reading JSON from stdin

Capture also supports reading in JSON from stdin. It will do it's best to find URL's within the data structure. For example, all of the following data structures are valid input:

Array of strings:

capture << EOF
[ "http://your-domain.com" ]
EOF

Array of Objects with property of url:

capture << EOF
[ { "url": "http://your-domain.com" } ]
EOF

Object with property of url:

capture << EOF
{ "url": "http://your-domain.com" }
EOF

Example Use Cases

Capture was written to aid in regression testing of websites where large cross-cutting changes to things such as CSS were made and we wished to understand the visual differences that might exist between an existing version of a site and the newly modified version. To accomplish this, Capture, coupled with Crawl allows us to take screenshots of both the old and new versions of the site, then perform image differencing on the results. One handy tool for performing the image differencing is a Mac app called Kaleidoscope.

The MIT License

Copyright (c) Mike Moulton

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

capture-1's People

Contributors

joelcox avatar mmoulton avatar

Watchers

 avatar  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.