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.
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);
}`
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 {
// image 1
// image 2
// result image