我有两个图像 I-1 和 I-2,我能够成功地使用 im4java 比较这两个图像。但是现在 I-1 和 I-2 的大小不同,因此当我尝试比较这两个图像时,它不会比较它们并给出消息
例如: org.im4java.core.CommandException:org.im4java.core.CommandException:compare.exe:图像宽度或高度不同`C:\Users\hp\workspace-getlinks-multipurpose\links_extractor/snapshots/actuals/id-dashboard .jpg'@error/compare.c/CompareImageCommand/990。
以下是我的代码:
      public static boolean compareImages(String exp, String cur,String output) {
    // This instance wraps the compare command
    CompareCmd compare = new CompareCmd();
    // For metric-output
    //compare.setErrorConsumer(StandardStream.STDERR);
    IMOperation cmpOp = new IMOperation();
    // Set the compare metric
    cmpOp.metric("mae");
//  cmpOp.addSubOperation(subimageSearch());
    // Add the expected image
    cmpOp.addImage(exp);
    // Add the current image
    cmpOp.addImage(cur);
    // This stores the difference
    cmpOp.addImage(output); 
    try {
        // Do the compare
        compare.run(cmpOp);
        return true;
    } catch (Exception ex) {
        System.out.println("ex: "+ex);
        return false;
    }
}