SkillAgentSearch skills...

Manet

Website screenshot service powered by Node.js, SlimerJS and PhantomJS

Install / Use

/learn @vbauer/Manet
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Manet Heroku Build Status Dependency Status NPM

There is only one true thing: instantly paint what you see. When you've got it, you've got it. When you haven't, you begin again. All the rest is humbug.

<img align="right" style="margin-left: 15px" width="300" height="360" title="Self-Portrait with Palette, 1879" src="misc/manet.jpg">

Manet is a REST API server which allows capturing screenshots of websites using various parameters. It is a good way to make sure that your websites are responsive or to make thumbnails.

Manet could use different engines to work: SlimerJS or PhantomJs.

Project was named in honor of Édouard Manet, French painter (1832-1883). He was one of the first 19th-century artists to paint modern life, and a pivotal figure in the transition from Realism to Impressionism.

Main features

  • Ready-To-Use
  • Supporting SlimerJS and PhantomJS
  • Configurable CLI application
  • Flexible REST API
  • File caching
  • Various image formats
  • Sandbox UI

Setup

Preset

Choose and install needed engine (PhantomJS, SlimerJS, or both of them):

SlimerJS:

  • You can download SlimerJS from the official site and install manually.
  • or you can use the power of NPM:
npm install -g slimerjs

Gecko, the rendering engine of Firefox, cannot render web content without a graphical window, but you can launch SlimerJS with xvfb if you are under linux or MacOSx, to have a headless SlimerJS, so it is also necessary to install Xvfb (X virtual framebuffer) for *nix or OS X systems.

For example, you can use apt-get to install xvfb on Ubuntu:

sudo apt-get install xvfb

PhantomJS

  • You can download PhantomJS from the official site and install manually.
  • or you can also use NPM:
npm install -g phantomjs

or (to use second version):

npm install -g phantomjs2

IMPORTANT: PhantomJS is used by default (see default.yaml file).

Installation

After preliminaries operations you can install Manet using NPM:

npm install -g manet

That is all, now you can start and use Manet server. As you can see, it is unnecessary to clone Git repository or something else.

Server launching

Server launching is a simple as possible:

manet

If everything is OK, you should see the following message:

info: Manet server started on port 8891

Server configuration

Manet server uses hierarchical configurations to cover differnet usage use-cases:

  • Command-line parameters
  • Environment variables
  • Built-in configuration YAML file ("config/default.yaml")

Rules of overriding:

  • Each configuration level could be overridden by another level.
  • The most-priority parameters are command-line parameters.
  • The less-priority parameters are stored in build-in configuration file.

CLI parameters

<dl> <dt>--host</dt> <dd>Web server host (default: "0.0.0.0"). Usually, it is unnecessary to change this parameter.</dd> <dt>--port</dt> <dd>Web server port number. REST API and UI will be available on this port (default: "8891").</dd> <dt>--engine</dt> <dd>Default engine for screenshot capturing: "phantomjs" or "slimerjs" (default is "phantomjs"). Specific command will be detected by configuration file (default.yaml) using engine parameter and OS platform.</dd> <dt>--command</dt> <dd>Configuration file "default.yaml" supports specific commands for different platforms (ex: "linux": "xvfb-run -a slimerjs"). Needed command will be detected in runtime by platform/OS. This parameter allows to override command for executing SlimerJS. It allows using full power of SlimerJS command line options to configure proxy, SSL protocol, etc. More information could be found here: http://docs.slimerjs.org/current/configuration.html <br/><b>IMPORTANT:</b> This parameter overrides "--engine" parameter.</dd> <dt>--storage</dt> <dd>File storage for cache (default is global temp directory).</dd> <dt>--cache</dt> <dd>Lifetime for file cache in seconds. Screenshots are cached for <i>60 minutes by default</i>, so that frequent requests for the same screenshot don't slow the service down. You can configure longer life for cache items or make them ethereal (use zero or negative value).</dd> <dt>--cleanupStartup</dt> <dd>Clean up FS storage on server startup (default is "false"). It removes all files which were stored previously.</dd> <dt>--cleanupRuntime</dt> <dd>Clean up FS storage at server runtime (default is "false"). It removes file with captured image after sending on client.</dd> <dt>--compress</dt> <dd>Additional compression for captured screenshots using <a href="https://github.com/imagemin/imagemin">Imagemin</a> (default is "false"). File sizes are significantly reduced due to this, but it requires additional processing time. Furthermore, imagemin is an optional dependency. It will be downloaded and installed in runtime during the first request, so it will take an additional time (one time).</dd> <dt>--silent</dt> <dd>Run Manet server with or without logging information (default is "false").</dd> <dt>--level</dt> <dd>Setting the level for your logging message. Possible values: debug, info, silly, warn, error (default is "info"). If want to investigate some problem with Manet, use "debug" level: --level=debug</dd> <dt>--cors</dt> <dd>Enable <a href="http://www.w3.org/TR/cors/">Cross-Origin Resource Sharing</a> (default is "false").</dd> <dt>--ui</dt> <dd>Enable or disable sandbox UI (default is "true").</dd> <dt>--timeout</dt> <dd>Number of milliseconds to wait for the program to complete before sending it "SIGTERM" (default is "60000").</dd> <dt>--options:{option}</dt> <dd>Default query parameters. See also "Query parameters" for more details. Example: "--options:width 101".</dd> <dt>--whitelist</dt> <dd>List of <a href="https://github.com/snd/url-pattern">URL patterns</a> that are allowed to be processed by Manet (all URLs are permitted by default).</dd> <dt>--security:basic:username</dt> <dd>Configure user name for <a href="https://en.wikipedia.org/wiki/Basic_access_authentication">Basic authentication</a>. Basic auth will be switched on when "username" and "password" are configured.</dd> <dt>--security:basic:password</dt> <dd>Configure password for Basic authentication.</dd> </dl>

Configuration file

Built-in configuration could be found in manet directory. For example, on Ubuntu it is located here: "/usr/local/lib/node_modules/manet/".

Default configuration file ("default.yaml"):

host: 0.0.0.0
port: 8891
cors: false
ui: true

silent: false
level: info

engine: phantomjs
timeout: 60000
compress: false
cache: 3600
cleanupStartup: false
cleanupRuntime: false

commands:
    slimerjs:
        linux: "xvfb-run -a slimerjs"
        freebsd: "xvfb-run -a slimerjs"
        sunos: "xvfb-run -a slimerjs"
        darwin: "slimerjs"
        win32: "slimerjs.bat"
    phantomjs:
        linux: "phantomjs --ignore-ssl-errors=true --web-security=false"
        freebsd: "phantomjs --ignore-ssl-errors=true --web-security=false"
        sunos: "phantomjs --ignore-ssl-errors=true --web-security=false"
        darwin: "phantomjs --ignore-ssl-errors=true --web-security=false"
        win32: "phantomjs --ignore-ssl-errors=true --web-security=false"

whitelist:
    - "*"

security:
    basic:
#        username: admin
#        password: admin

REST API

REST API is available on "/" using:

  • GET method
  • POST method with Content-Type:
    • application/json
    • or application/x-www-form-urlencoded

Few rules:

  • The "url" parameter must be specified.
  • It is possible to send data using query parameters or HTTP Message Body.
  • Query parameters will be used in priority and override others.

Available parameters

<dl> <dt>url</dt> <dd>Website address (URL). This is the only required parameter for the HTTP request. It is unnecessary for the most cases to configure scheme. Example: "github.com".</dd> <dt>width</dt> <dd>This property allows to change the width of the viewport, e.g., the size of the window where the webpage is displayed (default: `1024`)</dd> <dt>height</dt> <dd>This property allows to change the height of the viewport. If width is defined and height is not defined, than full page will be captured.</dd> <dt>paperFormat</dt> <dd>Paper format for PDF export (default is `letter`). Possible values: letter, A2, A3, A4, A5.</dd> <dt>paperOrientation</dt> <dd>Paper orientation for PDF export (default is `portrait`). Possible values: portrait, landscape.</dd> <dt>clipRect</dt> <dd>This property defines the rectangular area of the web page to be rasterized. Format: "top,left,width,height", example: "20,20,640,480".</dd> <dt>zoom</dt> <dd>Zoom factor of the webpage display. Setting a value to this property decreases or increases the size of the web page rendering. A value between 0 and 1 decrease

Related Skills

View on GitHub
GitHub Stars575
CategoryDevelopment
Updated15d ago
Forks102

Languages

JavaScript

Security Score

100/100

Audited on Mar 12, 2026

No findings