我正在使用Eclipse JUNO
JDK 7
im4java-1.4.0

当我执行Java程序时,我面临以下问题

org.im4java.core.CommandException: org.im4java.core.CommandException: compare.exe


我的代码是:

public static void main(String[] args) {
    String imPath = "D:/ImageMagick-6.8.5-Q16";
    ProcessStarter.setGlobalSearchPath(imPath);
    System.out.println(imPath);

    File image1 = new File("src//test//one.png");
    File image2 = new File("src//test//two.png");

    CompareCmd compareCmd = new CompareCmd();
    compareCmd.setSearchPath(imPath);

    IMOperation imOperation = new IMOperation();
    imOperation.metric("MAE");
    imOperation.addImage(image1.getAbsolutePath());
    imOperation.addImage(image2.getAbsolutePath());

    try {
        compareCmd.run(imOperation);
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    catch (InterruptedException e) {
        e.printStackTrace();
    }
    catch (IM4JavaException e) {
        e.printStackTrace();
    }
}


请给我建议。提前致谢。

最佳答案

将ImageMagick的路径添加到PATH变量中。以及

CompareCmd compareCmd = new CompareCmd();
compareCmd.setSearchPath("D:/ImageMagick-6.8.5-Q16");

08-16 05:02