Skip to content

A Scala project to take full size screenshot of a webpage in different dimensions.

License

Notifications You must be signed in to change notification settings

diamantidis/scala-screenshots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Screenshots

Scala CI codecov License: MIT Follow @diamantidis_io on Twitter

A Scala project to take full size screenshot of a webpage in different dimensions.

This project was build as a demo for the post "A Scala script to take full size webpage screenshots for different screen dimensions" that I published on my personal blog. You can always refer to the post if you want to find more information about this project.

Requirements

Installation

  • Download the project by executing the following commands:

    git clone -b source https://github.com/diamantidis/scala-screenshots.git
    cd scala-screenshots
  • If you want to install the script globally, the repo contains a Makefile with a target to install. This target use sbt-native-packager to generate an archive and then create a symlink to /usr/local/bin.

    make install
  • Otherwise, you can use SBT to run the program from the project directory. See Usage section.

Usage

  • To configure the program, create a json file with the following format:

    {
        "host": "the host",
        "urls": [
            "a url to take screenshot for"
        ],
        "dimensions": [
            {
                "width": 1920,
                "height": 1080
            }
        ]
    }

    For more details about this file, refer to the section Configuration.

  • Run

    • From project directory With SBT:
      sbt "run --config config.json"
    • From any directory, after installing using make install:
      scala-screenshots --config config.json
  • Run tests

    sbt clean test
  • Run tests with coverage

    sbt clean coverage test coverageReport
  • Run scalafmt task

    sbt scalafmtAll

Configuration

To configure Scala-screenshot, create a json file and pass it as a value for the --config argument. The following parameters can be configured:

  • Parameters

    • host: The host of the website.
    • urls: A list of strings with the urls to take screenshots for.
    • dimensions: A list of Dimension objects. Each object should have a width and a height key with a numeric value. The script will take screenshot for each of these dimensions.
  • An example:

    {
        "host": "https://diamantidis.github.io",
        "urls": [
            "2020/04/19/scala-script-for-fullsize-screenshots-for-different-screen-dimensions"
        ],
        "dimensions": [
            {
                "width": 1920,
                "height": 1080
            },
            {
                "width": 414,
                "height": 896
            }
        ]
    }

License

This project is licensed under the terms of the MIT license. See the LICENSE file.

Contact me

About

A Scala project to take full size screenshot of a webpage in different dimensions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published