裁剪并比较java中的两个图像示例
我试图裁剪并比较两个图像,因此创建了此方法,将以下字符串作为命令行返回给终端:
public static String compare(String samplePath, String screenshotPath, String diffFolder) {
return "convert " + samplePath+ " "+screenshotPath+" -crop 1010x1918 +repage miff:- | compare -metric RMSE - "+diffFolder+"_cropped_diff.png";
}
终端的输出如下所示:
convert img1.png screenshot1.png -crop 1010x1918 +repage miff:- | compare -metric RMSE - result/cropped_diff.png
但它返回给我以下输出:
compare.im6: image widths or heights differ `/tmp/magick-ZdZuQPMb' @ error/compare.c/CompareImageCommand/962.
我的问题是,为什么我不能在比较之前裁剪图像?我的命令行出了什么问题
Thanks for the help, I figure it out, I was missing the x and y coordinates so that's why the command line wasn't working properly. :) It should be "...-crop 1920x1080+x-y .
# 1 楼答案