java处理图片时使用im4java异常

hf201429 发布于 2016/05/24 17:19
阅读 904
收藏 0

我在使用im4java处理图片的时候,执行出错。求高手帮我查看下,一下为报错信息:

org.im4java.core.CommandException: java.io.IOException: Cannot run program "gm": CreateProcess error=2, ϵͳÕҲ»µ½ָ¶
    at org.im4java.core.ImageCommand.run(ImageCommand.java:219)
    at com.jiji.upload.service.util.ImageUtil.getDimension(ImageUtil.java:148)
    at com.jiji.upload.service.util.ImageUtil.main(ImageUtil.java:169)
Caused by: java.io.IOException: Cannot run program "gm": CreateProcess error=2, ϵͳÕҲ»µ½ָ¶
    at java.lang.ProcessBuilder.start(Unknown Source)
    at org.im4java.process.ProcessStarter.startProcess(ProcessStarter.java:407)
    at org.im4java.process.ProcessStarter.run(ProcessStarter.java:312)
    at org.im4java.core.ImageCommand.run(ImageCommand.java:215)
    ... 2 more
Caused by: java.io.IOException: CreateProcess error=2, ϵͳÕҲ»µ½ָ¶
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    ... 6 more

代码:

 public static int[] getDimension(String imagePath) throws Exception {
        IMOperation op = new IMOperation();
        op.format("%w %h");
        op.addImage(imagePath + FIRST_IMAGE);

        ArrayListOutputConsumer output = new ArrayListOutputConsumer();
        IdentifyCmd identify = new IdentifyCmd(true);
        identify.setOutputConsumer(output);
        identify.run(op);

        ArrayList<String> cmdOutput = output.getOutput();
        int[] size = new int[2];
        if (null != cmdOutput && cmdOutput.size() == 1) {
            String[] outSize = cmdOutput.get(0).split(" ");
            size[0] = Integer.parseInt(outSize[0]);
            size[1] = Integer.parseInt(outSize[1]);
        }
        return size;
    }


加载中
返回顶部
顶部