Giter VIP home page Giter VIP logo

screenie-server's Introduction

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 (default 1024).
  • SCREENIE_HEIGHT: Default height, as integer, in pixels (default 768).

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 (default jpeg).

The Puppeteer pool can also be customized with environment variables:

  • SCREENIE_POOL_MIN: Minimum number of Puppeteer instances (default 2).
  • SCREENIE_POOL_MAX: Maximum number of Puppeteer instances (default 10).

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 (default info).

To open up file scheme in URL parameter:

  • SCREENIE_ALLOW_FILE_SCHEME: true (default false).

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 (default 50).

And lastly, of course the HTTP port can be customized:

  • SCREENIE_PORT: HTTP port (default 3000).

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.

screenie-server's People

Contributors

fdanielsen avatar stianpr avatar asteinlein avatar dependabot[bot] avatar zhangheli avatar anfedorov avatar

Stargazers

 avatar 7a6163 avatar Martin van Driel avatar Marc Köhlbrugge avatar Valentin Vieriu avatar Abhishek Gahlot avatar  avatar Webdesign29 avatar hehuolong avatar  avatar  avatar  avatar dengch avatar Gastón Funes avatar Leandro Ardissone avatar  avatar Diego avatar Jason Davis avatar Garrett Wolf avatar Omer Zach avatar

Watchers

 avatar Jason Davis avatar  avatar James Cloos avatar  avatar Mahfuzur Rahman avatar

screenie-server's Issues

Screenshots fails when you add a PDF as url

Screenshots fails when you add a PDF as url. I don't think there is a way to render the pdf but at least we should avoid trying to render.
The basic effort can be to ignore url containing .pdf for a start

Install error

Hi,
Install don't work for me on windows seven with node.js 8.9.4 LTS and 9.5.0 Current.
npm install screenie-server
C:\temp>npm install screenie-server
npm ERR! code ENOGIT
npm ERR! No git binary found in $PATH
npm ERR!
npm ERR! Failed using git.
npm ERR! Please check if you have git installed and in your PATH.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tmeziere\AppData\Roaming\npm-cache_logs\2018-02-13T20_27_
21_463Z-debug.log
2018-02-13T20_27_21_463Z-debug.log

I'm relatively newbie on Node.js, maybe I've misunderstand something...
I've tried to install dependencies individually and launch server.js
C:\temp>node server.js
2018-02-13T21:07:17.817Z - info: Screenie server started on port 3000
2018-02-13T21:08:29.345Z - error: instance.process is not a function
2018-02-13T21:08:29.567Z - error: instance.process is not a function
but get an internal server error at http://localhost:3000/?url=http://google.com/&format=jpeg

Kind regards

add option to resize the screenshot

Add the option to resize the screenshot to create thumbnails.
I was using sharp in the past. This can open the way to add more file formats. Think of WEBP for example

Docker container can no longer load some https URLs

I'm having a hard time debugging why, but it looks like your docker container no longer loads https:

 docker run -p3000:3000 eliksir/screenie-server &
 [1] 51718
 Screenie server started on port 3000

andy:~ andrey$ curl -I http://localhost:3000/?url=https://sigma-static-files.imgix.net/uspalogo.png
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
Content-Length: 9
Date: Sat, 01 Jul 2017 03:19:19 GMT
Connection: keep-alive

andy:~ andrey$ curl -I http://localhost:3000/?url=http://sigma-static-files.imgix.net/uspalogo.png
HTTP/1.1 200 OK
Content-Type: image/jpeg
Content-Length: 27874
Date: Sat, 01 Jul 2017 03:19:23 GMT
Connection: keep-alive

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.