npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@magiclab/vrt-runner

v0.1.0

Published

VRT runner and result generator for images

Downloads

27

Readme

@magiclab/vrt-runner

VRT runner and result generator for images

VRT Example

CLI

npx @magiclab/vrt-runner --cwd path_to_diff_images --output result_output

It expects the files to have a simple folder syntax

path_to_diff_images
├── baseline
│   ├── 1.png
│   └── 2.png
└── test
    ├── 1.png
    └── 2.png

Change options via CLI, e.g. comparison diff threshold

    npx @magiclab/vrt-runner --cwd path_to_diff_images --output result_output --matchingThreshold 0.25

| Variable Name | Description | | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --ignoreChange | If true, error will not be thrown when image change detected. Default true | | --matchingThreshold | Matching threshold, ranges from 0 to 1. Smaller values make the comparison more sensitive. 0.05 by default. 0 by default for reg-cli. | | --thresholdRate | Rate threshold for detecting change. When the difference ratio of the image is larger than the set rate detects the change. Applied after matchingThreshold. | | --thresholdPixel | Pixel threshold for detecting change. When the difference pixel of the image is larger than the set pixel detects the change. This value takes precedence over thresholdRate. Applied after matchingThreshold. | | --concurrency | How many processes launches in parallel. If omitted 4 | | --enableAntialias | Enable antialias. If omitted true | | --additionalDetection | Enable additional difference detection(highly experimental). Select "none" or "client" (default: none). |

Node

You can also use it as a node module

import runVrt from '@magiclab/vrt-runner';

runVrt({
    cwd,
    output,
    teamcity, // boolean flag to know if we should log teamcity friendly output
    options, // optional: parameters for reg-cli
});

Hooks

Currently we support onVrtComplete hook, which allows you to get results of comparison and timing of comparison.

One of the ways to use this data is the following:


(async function() {
    try {
        // define action
        const onVrtCompleteAction: onVrtCompleteType = (result, cmpTime) => {
            const info = showResults({
                failedItems: result.failedItems.length + result.deletedItems.length,
                passed: result.passedItems.length + result.newItems.length,
                diffTime: cmpTime / 1000,
            });

            return info;
        };

        // save data after runVrt
        const info = await runVrt({
            cwd,
            output,
            teamcity, // boolean flag to know if we should log teamcity friendly output
            onVrtComplete: onVrtCompleteAction
        });

        // work with data
        console.log(info);
    }
    process.exit(0);
})();

How to change options for reg-cli instance

You might want to change the different comparison options in instances of vrt-runner. You can do it via options, which are are aligned with pixelmatch API

Change comparison diff threshold in Node

    const options = {
        matchingThreshold: 0.2
    };

    const vrtIntance01 = runVrt({
        cwd,
        output,
        teamcity, // boolean flag to know if we should log teamcity friendly output
        options,
    });

    const optionsSecondType = {
        matchingThreshold: 0.2
    };

    const vrtIntance03 = runVrt({
        cwd,
        output,
        teamcity, // boolean flag to know if we should log teamcity friendly output
        optionsSecondType,
    });

    const vrtIntance03 = runVrt({
        cwd,
        output,
        teamcity, // boolean flag to know if we should log teamcity friendly output
    });
})();

Assets

CSS files for the report page are generated. If you need to make changes to it, update src/report-assets/css/vrt.scss and run the following command:

    yarn styles