【发布时间】:2010-09-05 11:11:43
【问题描述】:
我在图像魔法中遇到了一个看起来很奇怪的新问题.. 我正在使用 mac osx 雪豹,我已经在它上面安装了 image magick,它在命令上工作正常.. 但是当我像下面的 sn-p 从 grails 类中调用它时,它给了我 "无法运行程序 "convert": error=2, No such file or directory"
代码是:-
public static boolean resizeImage(String srcPath, String destPath,String size) {
ArrayList<String> command = new ArrayList<String>(10);
command.add("convert");
command.add("-geometry");
command.add(size);
command.add("-quality");
command.add("100" );
command.add(srcPath);
command.add(destPath);
System.out.println(command);
return exec((String[])command.toArray(new String[1]));
}
private static boolean exec(String[] command) {
Process proc;
try {
//System.out.println("Trying to execute command " + Arrays.asList(command));
proc = Runtime.getRuntime().exec(command);
} catch (IOException e) {
System.out.println("IOException while trying to execute " );
for(int i =0 ; i<command.length; i++) {
System.out.println(command[i]);
}
return false;
}
//System.out.println("Got process object, waiting to return.");
int exitStatus;
while (true) {
try {
exitStatus = proc.waitFor();
break;
} catch (java.lang.InterruptedException e) {
System.out.println("Interrupted: Ignoring and waiting");
}
}
if (exitStatus != 0) {
System.out.println("Error executing command: " + exitStatus);
}
return (exitStatus == 0);
}
我已经尝试过像 ls 这样的普通命令,没关系,所以问题是 grails 无法找到转换命令本身.. 是操作系统问题还是什么?
【问题讨论】:
标签: macos grails imagemagick