【发布时间】:2014-12-07 18:16:55
【问题描述】:
我有以下 java 代码来模糊图像中的面孔 - 变量 convert 设置为 /usr/bin/mogrify
//String []cmd = {convert, "-region", f.w+"x"+f.h+"+"+x+"+"+y, "-blur 0.0x10.0", path};
String cmd = convert + " -region " + f.w+"x"+f.h+"+"+x+"+"+y + " -blur 0.0x10.0 " + "\"" + path + "\"";
System.out.println(cmd);
// System.out.println(strJoin(cmd, " "));
Process p = Runtime.getRuntime().exec(cmd);
BufferedReader in = new BufferedReader(
new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
p.waitFor();
但是图像上没有任何反应。
程序还会输出它会调用的命令行,例如:
/usr/bin/mogrify -region 37x44+1759+881 -blur 0.0x10.0 "/home/self/.wine/drive_c/windows/profiles/self/My Pictures/test/pic00164.jpg"
如果我手动调用此行,一切正常。
正如您从 cmets 中看到的,我还尝试将 cmd 作为一个数组提供,它应该会自动转义路径中的空格 - 效果相同:无。
【问题讨论】:
-
一切正常。尝试使用
p.getErrorStream()而不是p.getInputStream()来获取错误描述。
标签: java imagemagick