GitHub - 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.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. - GitHub - 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://github.com/romankh3/image-comparison
1、引用jar包
<dependency>
<groupId>com.github.romankh3</groupId>
<artifactId>image-comparison</artifactId>
<version>4.4.0</version>
</dependency>
2、参考代码
/**
* 图片比较演示 https://github.com/romankh3/image-comparison
* 【Github官方图片,略有小改动】
*
* @author chendd
* @date 2023/7/8 14:37
*/
public class GithubImageComparisonTest {
public static void main(String[] args) {
//加载图片
BufferedImage expectedImage = ImageComparisonUtil.readImageFromResources("Expected.png");
BufferedImage actualImage = ImageComparisonUtil.readImageFromResources("Actual.png");
//对比两个图片
ImageComparisonResult imageComparisonResult = new ImageComparison(expectedImage, actualImage).compareImages();
String folder = ImageComparisonUtil.class.getClassLoader().getResource("").getPath();
//存储图片和输出结果
ImageComparisonUtil.saveImage(new File(folder , "Github图片对比结果.png") , imageComparisonResult.getResult());
System.out.println("Github图片对比状态:" + imageComparisonResult.getImageComparisonState());
本文介绍了GitHub上romankh3发布的image-comparisonJava库,用于比较大小相同的图片并可视化展示差异,可排除部分区域,适用于自动化QA测试。展示了如何在项目中引用和使用该库进行图片对比。



964

被折叠的 条评论
为什么被折叠?



