Code Monkey home page Code Monkey logo

url-to-png's Introduction

URL to PNG logo
URL to PNG

Docker Build Image Size Pulls Version

A URL to PNG generator over HTTP with a fairly simple API accessed via query params passed to the servers single endpoint.

  • url: string - Valid URL to be captured - Required
  • width: number - Width of output screenshot - Optional - Default: 250
  • height: number - Height of output screenshot - Optional - Default: 250
  • viewPortWidth: number - Width of render viewport - Optional - Default: 1080
  • viewPortHeight: number - Height of render viewport - Optional - Default: 1080
  • forceReload: boolean - Force cached image reload - Optional - Default: false
  • isMobile: boolean - Adds mobile flag to user agent - Optional - Default: `false
  • isFullPage: boolean - Render full page instead of viewport crop - Optional - Default: false
  • isDarkMode: boolean - Prefer color scheme dark - Optional - Default: false
  • deviceScaleFactor: number - Specify device scale factor (can be thought of as dpr) - Optional - Default: 1

How to Use:

A) Docker

Run the following command:

docker run --rm -p 3000:3000 jasonraimondi/url-to-png

On the hub: Link to DockerHub

B) Local Serve

Serve the project

git clone [email protected]:jasonraimondi/url-to-png.git
cd url-to-png
npm install
npm run dev

Up and Running?

Navigate to localhost:3000?url=https://www.jasonraimondi.com and you should get back an image capture of my website homepage.

Go ahead and try any of the following:

http://localhost:3000?url=https://jasonraimondi.com
http://localhost:3000?url=https://jasonraimondi.com&forceReload=true
http://localhost:3000?url=https://jasonraimondi.com&isFullPage=true
http://localhost:3000?url=https://jasonraimondi.com&isMobile=true
http://localhost:3000?url=https://jasonraimondi.com&isDarkMode=true
http://localhost:3000?url=https://jasonraimondi.com&width=400&height=400
http://localhost:3000?url=https://jasonraimondi.com&viewPortHeight=400&viewPortWidth=400
http://localhost:3000?url=https://jasonraimondi.com&viewPortHeight=400&viewPortWidth=400
http://localhost:3000?url=https://jasonraimondi.com&isFullPage=true&isMobile=true&width=400&height=400&viewPortHeight=400&viewPortWidth=400
http://localhost:3000?url=https://jasonraimondi.com&isMobile=true&isFullPage=true&viewPortWidth=375&width=375&deviceScaleFactor=1

System Requirements

The following is cut from the Playwright documentation, please view the official system requirement documentation for the most up to date requirements guide.

Playwright requires Node.js version 10.15 or above. The browser binaries for Chromium, Firefox and WebKit work across the 3 platforms (Windows, macOS, Linux):

  • Windows: Works with Windows and Windows Subsystem for Linux (WSL).
  • macOS: Requires 10.14 or above.
  • Linux: Depending on your Linux distribution, you might need to install additional dependencies to run the browsers.
    • Firefox requires Ubuntu 18.04+
    • For Ubuntu 18.04, the additional dependencies are defined in the playwright Docker image, which is based on Ubuntu.

Allow List

Allow domain specific requests by passing in an ALLOW_LIST. The list should be comma separated, not include spaces, and should be the domain name only.

If this value is either undefined || "", url-to-png will allow any domain to be rendered.

ALLOW_LIST=jasonraimondi.com,github.com

Playwright Options

Please see the Playwright API documentation here for further knowledge.

BROWSER_TIMEOUT=
BROWSER_WAIT_UNTIL=

BROWSER_TIMEOUT

The maximum navigation time in milliseconds, pass 0 to disable timeout. The default value is 10000

BROWSER_WAIT_UNTIL

When playwright to considers the navigation succeeded. The default value for this option is domcontentloaded

Valid Options:

  • 'load' - consider operation to be finished when the load event is fired.
  • 'domcontentloaded' - consider operation to be finished when the DOMContentLoaded event is fired.
  • 'networkidle' - consider operation to be finished when there are no network connections for at least 500 ms.

Image Storage / Cache

NOTE: If you are running in Docker, you should skip the .env and load the environment variables into your container.

You are going to need to copy the environment file to use any of the storage options. By default no images are cached.

cp .env.sample .env

AWS S3

To use Amazon S3 set STORAGE_PROVIDER=s3, ensure the following variables are loaded in your .env:

STORAGE_PROVIDER=s3
AWS_ACCESS_KEY=
AWS_SECRET_KEY=
AWS_REGION=
AWS_BUCKET=

CouchDB

To use CouchDB set STORAGE_PROVIDER=couchdb, ensure the following variables are loaded in your .env:

STORAGE_PROVIDER=couchdb
COUCH_DB_PROTOCOL=
COUCH_DB_HOST=
COUCH_DB_USER=
COUCH_DB_PASS=

Sources

url-to-png's People

Stargazers

 avatar

Watchers

 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.