screenie-server
v4.0.0
Published
A screenshot HTTP service using Puppeteer
Downloads
25
Readme
screenie-server
HTTP screenshot service based on Puppeteer.
Creates a HTTP server using Koa, by default on port 3000. It renders pages and creates screenshots of them on request.
Installation / Usage
You can install from npm and run the server manually:
npm install screenie-server
./node_modules/.bin/screenie-server
Alternatively, we provide a Docker image (built from the Dockerfile) at eliksir/screenie-server. This container is not running in sandbox mode because the Docker image doesn't support user namespaces.
Configuration
Then request a screenshot of an URL using the url
query parameter:
http://localhost:3000/?url=http://google.com/&format=jpeg
The size of the screenshot can be customized through the width
and height
query parameters, but will always be constrained within 2048x2048. The default
size used when the parameters are missing can be customized by environment
variables:
SCREENIE_WIDTH
: Default width, as integer, in pixels (default1024
).SCREENIE_HEIGHT
: Default height, as integer, in pixels (default768
).
The format
query parameter can be used to request a specific format of the
screenshot. The supported formats are PNG, JPEG and even PDF. You can
also set the default format through an environment variable:
SCREENIE_DEFAULT_FORMAT
: Default format (defaultjpeg
).
The Puppeteer pool can also be customized with environment variables:
SCREENIE_POOL_MIN
: Minimum number of Puppeteer instances (default2
).SCREENIE_POOL_MAX
: Maximum number of Puppeteer instances (default10
).
To control the level of logging that will be performed, customize the
SCREENIE_LOG_LEVEL
environment variable. Supported values are error
,
warn
, info
, verbose
, debug
, and silly
, though only info
and
verbose
are currently in use.
SCREENIE_LOG_LEVEL
: Logging level (defaultinfo
).
To open up file scheme in URL parameter:
SCREENIE_ALLOW_FILE_SCHEME
: true (defaultfalse
).
Delay from the load
event until the screenshot is taken. This can solve
issues with rendering (i.e. rendering webfonts) not being complete before the
screenshot.
SCREENIE_SCREENSHOT_DELAY
: Time in milliseconds (default50
).
And lastly, of course the HTTP port can be customized:
SCREENIE_PORT
: HTTP port (default3000
).
Contributing
We are open to contributions or suggestions. File issues or suggestions on the GitHub issues page, and please do submit a pull request if you have the time to implement an improvement or bugfix.
License
Published under the MIT license.