Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Reflection

Screenshot taking API built on top of Node(+ Express) Phantom and Mongo (+ Mongoose).

Dependencies

To run Reflection besides Node.js, PhantomJS and MongoDB, you need the following Node.js dependencies: Express, Mongoose, MooTools, Hogan, LESS, MD5 and marked.

To install the main dependencies for Mountain Lion, follow the Development Setup, after that, intall the node dependencies by typing $ sudo npm install in the aplication directory.

Usage

GET /export/:id.:format

Get the saved screenshot data based on an id. You can get either the image directly or a JSON representation for it.

  • /export/50b52cb7b002c2f352000001.png
  • /export/50b52cb7b002c2f352000001.json

Parameters

  • include_content (optional)

    When set to either true or 1, the JSON response will not contain the base64 image data. Omit this parameter to receive the complete data. (This parameter only affects the JSON response)

Output

{
	"_id": "50b52cb7b002c2f352000001",
	"format": "png",
	"output": "base64EncodedImageData",
	"location": "/export/50b52cb7b002c2f352000001.png"
}

POST /export

Create a new screenshot and save it into the database for later use. The request will return the same json response as a GET /export/_new_resource_id.json.

The include_content parameter can be used on the POST request as a query parameter to get the image data in the response.

Format

The request parameters need to be in the body and they can be either form-encoded or json:

  • input (defaults to null)

    Contains either a url of the page to capure, or the html content to render.

  • ouput_format (defaults to png)

    The output image format, supports png, jpg and gif.

  • output_screen_width (defaults to 960)

    The width of the browser screen when rendering the webpage.

  • output_screen_height (defaults to 640)

    The height of the browser screen when renedring the webpage. The screenshot can have a bigger height if there is content beyond the screen size.

  • output_zoom (defaults to 1)

    Zoom factor for the page.

  • settings_javascript_enabled (defaults to true)

    Enable javascript when rendering the webpage.

  • settings_load_images (defaults to true)

    Enable image loading when rendering the webpage.

Defaults

{
	"input": null,
	"output_format": "png",
	"output_screen_width": 960,
	"output_screen_height": 640,
	"output_screen_zoom": 1,
	"settings_javascript_enabled": true,
	"settings_load_images": true
}

Example

For example a request to take jpg screenshot of the http://delphi.us page rendered on a 1200 x 800 px screen will have the following post body:

  • input=http%3A%2F%2Fdelphi.us&output_format=jpg&output_screen_width=1200&output_screen_height=800

Author

Author(s): Claudiu Andrei

(C) Copyright 2012, Delphi Solutions

About

Basic Image API written in Node

Resources

Releases

No releases published

Packages

No packages published