romankh3 / image-comparison

Published on Maven Central Java Library that compares 2 images with the same sizes and shows the differences visually by drawing rectangles. Some parts of the image can be excluded from the comparison. Can be used for automation QA tests.
https://t.me/romankh3
Apache License 2.0
343 stars 105 forks source link

RED (not equals) and GREEN (ignored) areas are not shown at result image at the same time #113

Closed mrgoroua closed 5 years ago

mrgoroua commented 5 years ago

Actual: if there are several ignored rectangles was set and test has been failed because of defferences in other places -> only RED areas are shown at result image

Expected: failed and ignored areas are shown simultaneously at result image

`@Test public void testNotEquals() throws IOException {

    File ExpectedCash = new File(".\\helperfiles\\receipts\\receipt1.png");
    File ActualCash = new File(".\\helperfiles\\receipts\\receipt2.png");
    File resultDestination = new File(".\\helperfiles\\receipts\\resultImage.png");

    BufferedImage image1 = readImageFromFile(ExpectedCash);
    BufferedImage image2 = readImageFromFile(ActualCash);
    List<Rectangle> excludedAreas = new ArrayList<>();
    //excludedAreas.add(new Rectangle(60, 384, 915, 515)); -------- shown AS RED on result picture
    excludedAreas.add(new Rectangle(385, 515, 915, 565));  //  -- not shown at result picture
    excludedAreas.add(new Rectangle(385, 630, 915, 750));   // -- not shown at result picture

    ImageComparison imageComparison = new ImageComparison(image1, image2);
    imageComparison.setExcludedAreas(excludedAreas);
    imageComparison.setRectangleLineWidth(5);

    imageComparison.setDrawExcludedRectangles(true);
    ComparisonResult result = imageComparison.compareImages().writeResultTo(resultDestination);
    assertEquals(result.getComparisonState(), MATCH);

}`

// image 1 receipt1

// image 2 receipt2

// result image resultImage

romankh3 commented 5 years ago

@mrgoroua, added the fix for and published as 3.1.1 version. Please, check and close the issue.

mrgoroua commented 5 years ago

fixed