Chromda

λ 🖼️ Chromda is an AWS Lambda function for capturing screenshots of websites.
Alternatives To Chromda
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Chromda456
3 years agomitJavaScript
λ 🖼️ Chromda is an AWS Lambda function for capturing screenshots of websites.
Juicy951a month ago6November 01, 202044mitTypeScript
:tangerine: Awesome juicy lambdas for generating PDF, taking screenshots, transform XML to JSON, generate images from github readme, generate SVG icons, generate screenshots from Twitter/Facebok. Running on @vercel platform.
Whippersnapper50
8 years ago5November 14, 2014mitPython
Whippersnapper is an automated screenshot tool to keep a visual history of content on the web.
Chart To Aws43
5 years agoGo
Microservice to generate screenshot from a webpage and upload it to a AWS S3 Bucket.
Dynamon35
3 years ago3Swift
DynamoDB GUI Development Tools
Lambda Screenshot23
8 years agoJavaScript
A simple working example of an AWS Lambda screenshotting service using Node and PhantomJS.
Aws Lambda Benchmark17
4 years ago
A project that contains AWS Lambda function implementations for several runtimes e.g. Nodejs, Haskell, Python, Go, Rust, Java, etc.
Django Scrup15
14 years ago1bsd-3-clausePython
A django-based web receiver for Scrup which stores screencaptures on S3.
Serverless Screenshot Get1316 years ago6July 23, 2017JavaScript
Serverless AWS API for returning PNG data of a fresh web page screenshot
Panda Panopticon12
9 years ago7otherJavaScript
An AWS cloudwatch dashboard written in node.js using the AWS node.js SDK
Alternatives To Chromda
Select To Compare


Alternative Project Comparisons
Readme

Chromda – Serverless screenshots

Chromda is an AWS Lambda function for serverless capturing screenshots of websites.

Multiple sources

  • SNS topics
  • SQS queues
  • CloudWatch scheduled events
  • API Gateway proxy

Configurable

  • Capture full page, viewport or specific DOM element
  • Exclude DOM elements (useful for ads or other unwanted content)
  • Override styles

Quick start

Provided you already have AWS credentials for Serverless, do:

git clone https://github.com/luisfarzati/chromda
cd chromda
git submodule update --init
npm install

Edit the serverless.yml file and change the example bucket name with one of your own:

# serverless.yml
custom:
  s3Bucket: <your bucket name>

Deploy the function into your AWS account:

npm run deploy

Open the AWS Lambda Console and create the following test event:

{
  "source": "aws.events",
  "time": "1970-01-01T00:00:00Z",
  "detail": {
    "url": "https://www.nytimes.com"
  }
}

Click Test, wait a few seconds (it might take around 8-10 secs), then you should see a response like:

{
  "url": "https://<your bucket name>.s3.amazonaws.com/<uuid>.png"
}

Usage

Invocation

The function accepts different kind of events, extracting the data from the proper body attribute as follows:

Event Body is extracted from
SNS Message Event .Records[0].Sns.Message
SQS Message Event .Records[0].body
API Gateway Message Event .body
CloudWatch Events Message Event .detail

Options

{
  // required
  "url": "https://google.com",

  // optional - valid options: page, viewport, element
  // default: viewport
  "capture": "page",

  // selector of element to capture
  // required if capture: element
  "selector": ".container",

  // optional - S3 key for the image file
  // default: uuid()
  "s3key": "test.png",

  // optional - selectors of elements to exclude
  "exclude": [".ad", "video"],

  // optional - styles to override
  // see Puppeteer.addStyleTag
  "styles": [
    {
      "content": "body { color: #f00; }"
    }
  ],

  // optional - puppeteer options
  "puppeteer": {
    // see Puppeteer.goto options
    "navigation": {
      "timeout": 30000,
      "waitUntil": ["domcontentloaded", "networkidle2"]
    },
    // see Puppeteer.screenshot options
    "screenshot": {
      "type": "jpeg",
      "quality": 50,
      "omitBackground": false
    },
    // viewport size, overrides env defaults
    "viewport": {
      "width": 1200,
      "height": 2000
    }
  }
}

Environment Variables

Name Default
S3_BUCKET*
S3_REGION*
S3_ACL "public-read"
CHROMIUM_ARGS "[]"
TIMEOUT "30000"
IGNORE_HTTPS_ERRORS "false"
VIEWPORT_WIDTH "1920"
VIEWPORT_HEIGHT "1200"
DEVICE_SCALE_FACTOR "1"
IS_MOBILE "false"
IS_LANDSCAPE "false"

Deploy

# serverless.yml

# ...
custom:
  s3Bucket: <your bucket name>

provider:
  # ...
  layers:
    # Replace <version> with the latest version of chrome-aws-lambda-layer
    # It depends on the region you are deploying.
    # https://github.com/shelfio/chrome-aws-lambda-layer#available-regions
    - arn:aws:lambda:${self:provider.region}:764866452798:layer:chrome-aws-lambda:<version>

functions:
  captureScreenshot:
    # ...
    environment:
      # configure the environment variables
      VIEWPORT_WIDTH: "1920"
      VIEWPORT_HEIGHT: "1200"
      # ...
    events:
      # add any of the supported event source(s) you want to use
      # the provided example uses SNS
      - sns:
          arn: !Ref chromdaTopic
          topicName: ${self:custom.snsTopic}

resources:
  # following the example, we provision an SNS topic
  chromdaTopic:
    Type: AWS::SNS::Topic
    Properties:
      TopicName: ${self:custom.snsTopic}

X-Ray

AWS X-Ray support is provided and there are segments for Puppeteer navigation and screenshot:

AWS X-Ray screenshot

Popular Screenshot Projects
Popular Amazon Web Services Projects
Popular Media Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Javascript
Amazon Web Services
Lambda Functions
Serverless
Screenshot
S3
Aws Lambda
Puppeteer
Viewport
Chrome Headless