• Stars
    star
    277
  • Rank 148,875 (Top 3 %)
  • Language Smarty
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Grunt plugin for creating screenshots of any site and compare them

grunt-photobox

Build Status NPM version Dependency Status Code Climate Built with Grunt

image

Plugin to prevent your project of broken layout via screenshot photo sessions of your site.

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-photobox --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-photobox');

The "photobox" task

Overview

In your project's Gruntfile, add a section named photobox to the data object passed into grunt.initConfig().

grunt.initConfig({
  photobox: {
    task : {
      options: {
        // Task-specific options go here.
      }
    }
  },
})

Photobox helps you to not deploy any broken layout to production. It takes screenshots of you current site.

Additionally you got the feature, to keep the last photosession and to overlay old and new screenshots, to see even better if something is broken or not. BE ALWAYS SURE, THAT YOU HAVEN'T BROKEN LAYOUT THE EASY WAY.

ImageMagick and Canvas representation (generated diff):

image

Options

options.indexPath

Type: String

Default value: photobox/

A string value that is used to set the path to the generated images and index.html.

Per default a photobox folder will be generated and inside of that folder an index.html is located to check for broken layout.

options.screenSizes

Type: Array

Default value: [ '800' ]

[NOTE: Values like '800x600' are deprecated since version 0.5.0.]

An array containing strings, that represents the wished width in pixels of the taken pictures. The height will be calculated automatically depending on the given site.

E.g. '800' -> width: 800px;

options.urls

Type: Array

Default value: [ 'http://google.com' ]

An array containing strings, that represents the wished urls for the photosession.

options.relativePaths

Type: Boolean

Default value: false

If final images should contain only realative urls.

options.userName

Type: String

Default value: ``

A string representing the username in case of HTTP-Authentification.

options.password

Type: String

Default value: ``

A string representing the password in case of HTTP-Authentification.

options.template

Type: String|Object

Default value: canvas

A string value that is used to set the template to display your screenshots. Possible values:

  • canvas -> uses Canvas to show differences in screenshots.
  • magic -> uses ImageMagick to show the difference of old and new screenshots.

If you want to use ImageMagick by setting options.template to magic make sure ImageMagick and included commands are installed on your system:

Check the following commands in your environment:

$ which convert
/opt/local/bin/convert
$ which composite
/opt/local/bin/composite

If you want to pimp your via canvas generated diff images there is the option available to pass in an object as template instead of a string.

options : {
  ...
  template       : {
    name    : 'canvas',
    options : {
      highlightColor : '#0000ff',  //
      diffFilter     : 'grayscale' //  default == no filter 'grayscale' | 'darker' | 'brighter'
    }
  }
  ...
}
options.template.name

Type: String

Currently only supported set to canvas.

options.template.options.highlightColor

Type: String

Default value: '#0000ff'

A string representing a given color for highlighted different areas.

options.template.options.diffFilter

Type: String

Default value: default

4 modes for diff image processing are available:

  • default - image information in diff image will not be changed
  • grayscale - image information in diff image will be changed to grayscale
  • darker - image information in diff image will be changed to a darker image
  • brighter - image information in diff image will be change to a brighter image

+#### options.timeOut

Type: Integer

Default value: 1000

An Integer representing the delay in milliseconds after the screenshot should be taken.

Usage Examples

Default Options

In this example, the default options are used to do just show what is possible. Run grunt photobox without any custom options and you will get a new file at photobox/index.html.

It will consist of a screenshot for the default url ( http://google.com ) in the default width 800px.

grunt.initConfig( {
  photobox: {
    task: {
      options: {}
    }
  }
});

Options

Now let's customize everything for your needs.

grunt.initConfig( {
  photobox: {
    task: {
      options: {
        screenSizes : [ '600', '1000', '1200' ],
        urls        : [ 'http://yoursite.com', 'http://yoursite.com/blog', 'http://yoursite.com/catalog' ]
      }
    }
  }
} );

This will generate you 9 screenshots - each url in each size.

Canvas default usage

grunt.initConfig( {
  photobox : {
    waisenkinder : {
      options : {
        indexPath      : 'photobox/',
        highlightColor : '#0000ff',
        screenSizes    : [ '960', '350', '1200' ],
        template       : 'canvas',
        urls           : [ 'http://4waisenkinder.de' ]
      }
    }
  }
} );

Canvas configured usage

grunt.initConfig( {
  photobox : {
    waisenkinder : {
      indexPath      : 'photobox/',
      screenSizes    : [ '960', '350', '1200' ],
      template       : {
        name    : 'canvas',
        options : {
          highlightColor : '#0000ff',  // template.options.hightlightColor || highlightcolor || default
          diffFilter     : 'grayscale' //  'default' == no filter | 'grayscale' | 'darker' | 'brighter'
        }
      },
      urls           : [ 'http://4waisenkinder.de' ]
    }
  }
} );

ImageMagick usage

grunt.initConfig( {
  photobox : {
    waisenkinder : {
      options : {
        indexPath      : 'photobox/',
        screenSizes    : [ '960', '350', '1200' ],
        template       : 'magic',
        urls           : [ 'http://4waisenkinder.de' ]
      }
    }
  }
} );

Relative urls usage

grunt.initConfig( {
  photobox : {
    prod : {
      options : {
        screenSizes    : [ '480', '1200' ],
        relativePaths  : true,
        urls           : [ 'http://4waisenkinder.de' ]
      }
    },
    dev : {
      options : {
        screenSizes    : [ '480', '1200' ],
        relativePaths  : true,
        urls           : [ 'http://localhost:8080' ]
      }
    }
  }
} );

If the localhost:8080 and 4waisenkinder.de are the same pages, we can easily now compare them by running: ['photobox:prod', 'photobox:dev'] as the images will have relative paths names.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Donating

Support this project and others by stefanjudis via gittip.

Support via Gittip

Release History

Please check release history at Github. :)

Bitdeli Badge

More Repositories

1

tiny-helpers

A collection of useful online web development tools
JavaScript
930
star
2

perf-tooling

List of performance analysis, monitoring and optimization tools
JavaScript
644
star
3

grunt-phantomas

Grunt plugin wrapping phantomas to measure frontend performance
JavaScript
285
star
4

awesome-command-palette

A list of awesome command palette implementations.
195
star
5

credits-cli

Find out on whose work your project is based on
JavaScript
193
star
6

dotfiles

The setup I run on every computer
Shell
189
star
7

sparkly-text

A small web component for making your text spark.
JavaScript
179
star
8

web-vitals-element

A custom element to display web vitals metrics on your page.
JavaScript
172
star
9

netlify-menubar

Netlify menubar app to receive build information or trigger new builds
TypeScript
153
star
10

css-scroll-shadows

Website to quickly create CSS scroll shadows
JavaScript
139
star
11

is-http2-cli

CLI Module to check for http/2 support
JavaScript
51
star
12

browsers.fyi

Get browser versions as website or abpi
Nunjucks
31
star
13

sketch-contentful

A Sketch App plugin to populate your documents with data stored in Contentful.
JavaScript
28
star
14

create-phone-number-forwarding

A CLI tool to quickly buy a Twilio phone number and forward calls/SMS to another number
Shell
24
star
15

grunt-jsinspect

Grunt task for jsinspect
JavaScript
22
star
16

designMode-chrome-extension

Chrome extension to easily use document.designMode
JavaScript
22
star
17

github-light-dark-image-example

22
star
18

1-1-question-now

A quick app that gives you a question to ask in your one to one
JavaScript
21
star
19

just-write-a-fn

Example React app using netlify functions to send emails
JavaScript
20
star
20

tiny-teachers

A collection of online learning tools and courses for web developers.
Nunjucks
13
star
21

blocky

Application (Win/MacOS) to block screensaver and sleep mode easily
JavaScript
10
star
22

credits

Find out on whose work your project is based on
JavaScript
10
star
23

8-bit-revolution

Tell your friends how much you like 8-bit
JavaScript
9
star
24

caniuse-embed-element

JavaScript
8
star
25

extract-media

A command line utility to extract media from .key and .docx files
JavaScript
8
star
26

stefanjudis

HTML
8
star
27

mdx-contentful-ui-extension

Contentful UI extension to preview MDX
JavaScript
7
star
28

cushion-cli

The command line tool to control your CouchDB.
JavaScript
7
star
29

contentful-enriched-markdown

JavaScript
6
star
30

contentful-analytics-ui-extension

Embed Google Analytics in the Contentful UI
HTML
6
star
31

react-in-a-worker

Example of React running in the client, a service worker and cloudflare worker
JavaScript
6
star
32

pwt-workshop

A Playwright Test workshop
JavaScript
6
star
33

har-diff

Tool to get diff statistics of two har-files
JavaScript
5
star
34

travalizit-app

Web App to analysize travis build data.
JavaScript
5
star
35

alex-js-contentful-ui-extension

A Contentful UI extension to check for insensitive writing
HTML
5
star
36

contentful-link-checker-ui-extension

A UI extension to check for broken or invalid links
HTML
5
star
37

webComponents-tutorial

Example page for implementing web components via polymer.js
CSS
5
star
38

phantomas-ui

Create visually appealing dashboards with data gathered by phantomas
JavaScript
5
star
39

covery

JavaScript
4
star
40

today-i-learned

Example application of a universal React app running with Contentful on Netlify
JavaScript
4
star
41

contentful-graphql-course

JavaScript
4
star
42

npm-package-to-env

Load package.json data and make them accessible via process.env
JavaScript
4
star
43

a-better-contentful-home-dashboard

TypeScript
3
star
44

twilio-workshop

Twilio Workshop for Chat, Video and WhatsApp
JavaScript
3
star
45

create-module

Boilerplate for new Node.js projects
Shell
3
star
46

gatsby-starter-contentful-knowledge-base

JavaScript
3
star
47

confetti-element

JavaScript
3
star
48

pwt-workshop-solutions

TypeScript
3
star
49

electron-podcast

Example how to build a webview app
JavaScript
3
star
50

photobox

Module to create screenshots of your site and check if the layout has changed
JavaScript
3
star
51

jamstack-workshop

JavaScript
3
star
52

serverless-contentful-watermark

A serverless function to create Contentful images with watermarks
JavaScript
3
star
53

stefan-judis-website-editors

Contentful editors for my own site
JavaScript
3
star
54

podbot-functions

How to control Twilio voice calls with Serverless functions
JavaScript
3
star
55

jamstack-workshop-start

The beginning of the Jamstack Conf Next.js/Contentful workshop
JavaScript
3
star
56

electron-patch-fs

Monkey patch electrons fs functions with the original ones
JavaScript
3
star
57

webperf-101-workshop-final

Final material for the web performance workshop
JavaScript
2
star
58

alice-app

JavaScript
2
star
59

bouncer

Tool to evaluate impact of 3rd party script
JavaScript
2
star
60

github-actions-profile-readme-example

Example showing how to render a GitHub profile README including Contentful data with GitHub actions
JavaScript
2
star
61

phantomjs-screenshot

Script to make screenshots of a given site
JavaScript
2
star
62

webperf-101-workshop

Material for the web performance workshop
JavaScript
2
star
63

twilio-serverless-sms-group-chat

JavaScript
2
star
64

code-examples

2
star
65

electron-block-screensaver-example

Example project for Electron show off
JavaScript
2
star
66

stefan-judis-about

about.me clone
HTML
1
star
67

alice-generator

JavaScript
1
star
68

my-links-online

Serverless URL shortener using Contentful
JavaScript
1
star
69

the-responsible-developer

HTML
1
star
70

today-i-learned-dev

JavaScript
1
star
71

alfred-weigh

Alfred workflow to get bundles sizes using weigh
JavaScript
1
star
72

sync-tryout

Just testing stuff.
JavaScript
1
star
73

helen

CLI tool for har-diff report generation
JavaScript
1
star
74

bouncer-proxy

Proxy server to block certain requests via CSP
JavaScript
1
star
75

travalizit

Node.js Travis API
JavaScript
1
star
76

today-i-learned-spa

Example application of a React app running with Contentful on Netlify
JavaScript
1
star
77

hide-twitter-follower-extension

1
star
78

a-site-without-a-file-to-my-computer

Created with CodeSandbox
HTML
1
star
79

pw-fixtures

JavaScript
1
star
80

a-checkly-gh-sync-example

Example for Checkly Launch Week
JavaScript
1
star
81

contentful-usage-checker

Chrome extension to see which sites run on Contentful
JavaScript
1
star
82

a-picture-a-day

PWA to see yourself getting older taking a picture a day
1
star
83

phantomas-custom-metrics-tryout

Tryout page to show of phantomas custom metrics
CSS
1
star
84

guardcat

A utility to help you keep track of github notifications
JavaScript
1
star
85

animated-svg-favicon

Test to animate an SVG favicon
HTML
1
star
86

download-it-now

Serverless proxy function to trigger a download
1
star