Giter Site home page Giter Site logo

image-comparator's Introduction

GitHub forks GitHub stars GitHub watchers

Maven Central javadoc GitHub release badge-jdk License: MIT

Image Comparator

Table of Contents

Declaration

Gradle

Add dependency to build.gradle.

implementation("com.github.ngoanh2n:image-comparator:1.4.0")

Maven

Add dependency to pom.xml.

<dependency>
    <groupId>com.github.ngoanh2n</groupId>
    <artifactId>image-comparator</artifactId>
    <version>1.4.0</version>
</dependency>

Usage

Comparison

  1. Compare 2 images
    ImageComparisonOptions options = ImageComparisonOptions
            .builder()
            .allowedDeviation(0.05)         // Default to 0.0
            .diffColor(Color.CYAN)          // Default to Color.RED
            .build();
    ImageComparisonResult result = ImageComparator.compare(expectedImage, actualImage, options);
  2. Compare 2 image directories
    Path expectedImageDir = Paths.get("data/expected");
    Path actualImageDir = Paths.get("data/actual");
            
    ImageComparisonOptions options = ImageComparisonOptions
            .builder()
            .allowedDeviation(0.05)         // Default to 0.0
            .diffColor(Color.CYAN)          // Default to Color.RED
            .build();
    ImageBulkComparisonResult result = ImageComparator.compare(expectedImageDir, actualImageDir, options);

Result

ImageComparisonResult is the result of ImageComparator.compare(expectedImage, actualImage, options).

boolean isDifferent = ImageComparisonResult.isDifferent();
int diffSize = ImageComparisonResult.getDiffSize();
BufferedImage diffImage = ImageComparisonResult.getDiffImage();
double allowedDeviation = ImageComparisonResult.getAllowedDeviation();
double currentDeviation = ImageComparisonResult.getCurrentDeviation();

ImageBulkComparisonResult is the result of ImageComparator.compare(expectedImageDir, actualImageDir, options).

boolean hasDiff = ImageBulkComparisonResult.hasDiff();
int diffTotal = ImageBulkComparisonResult.getDiffTotal();
List<ImageComparisonResult> diffResults = ImageBulkComparisonResult.getDiffResults();

Visitor

ImageComparisonVisitor for walking through ImageComparator.

  • ImageComparisonVisitor.comparisonStarted(ImageComparisonOptions, BufferedImage, BufferedImage)
  • ImageComparisonVisitor.comparisonFinished(ImageComparisonOptions, BufferedImage, BufferedImage, ImageComparisonResult)

Output

ImageComparisonOutput for writing comparison output files to specified location.
An implementation of ImageComparisonVisitor.

  • The output is always created at build/ngoanh2n/img/{yyyyMMdd.HHmmss.SSS} by default
  • Use ImageComparisonResultOptions to adjust the output behaviors. And set to ImageComparisonOptions
    ImageComparisonResultOptions resultOptions = ImageComparisonResultOptions
           .builder()
           .writeOutputs(false)                       // Default to true
           //.location(Paths.get("build/custom"))     // Default to build/ngoanh2n/img
           .build();
    ImageComparisonOptions options = ImageComparisonOptions
           .builder()
           .resultOptions(resultOptions)              // Default to ImageComparisonResultOptions.defaults()
           .build();

Allure Report

When using Allure as a report framework, should use com.github.ngoanh2n:image-comparator-allure.
image-comparator-allure README.

image-comparator's People

Contributors

ngoanh2n avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.