java的image magick问题
具体来说,我正在尝试在 java 上运行下一行:
convert /home/mohamed.hegab/Desktop/1263392123111.jpg -gamma .45455 -resize 400x400 -gamma 2.2 -quality 92 /home/mohamed.hegab/Desktop/small.jpg
它在 bash 命令行上运行得很好 但是当我使用进程生成器在java上运行它时,它给了我奇怪的结果。
public static void resizeImage(String srcPath, String destPath,String size) {
ProcessBuilder pb = new ProcessBuilder("convert", srcPath , " -gamma", ".45455",
" -resize",size, " -gamma ", "2.2", " -quality",
"92" , destPath);
pb.redirectErrorStream(true);
InputStreamReader isr = null;
BufferedReader br = null;
try {
Process p = pb.start();
p.waitFor();
isr = new InputStreamReader(p.getInputStream());
br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (Exception e) {
LOG.error("Exception while trying to convert text to image", e);
} finally {
try {
if(isr != null) {
isr.close();
}
if(br != null) {
br.close();
}
} catch (IOException e) {
LOG.error("Could not close stream", e);
}
}
}
system.out 中的行很奇怪,它说:
convert:无法打开图像-gamma':没有这样的文件或目录@ blob.c/OpenBlob/2439。 转换:无法打开图像
.45455':没有这样的文件或目录@ blob.c/OpenBlob/2439。 转换:无法打开图像-resize':没有这样的文件或目录@ blob.c/OpenBlob/2439。 转换:无法打开图像
400x400':没有这样的文件或目录@ blob.c/OpenBlob/2439。 转换:无法打开图像 -gamma ':没有这样的文件或目录@ blob.c/OpenBlob/2439。 转换:无法打开图像
2.2':没有这样的文件或目录@ blob.c/OpenBlob/2439。 转换:无法打开图像-quality':没有这样的文件或目录@ blob.c/OpenBlob/2439。 转换:无法打开图像
92':没有这样的文件或目录@ blob.c/OpenBlob/2439。
但图像只有 960 *960 的尺寸,我不知道它来自哪里。
那么任何人都可以帮助我吗:)
to be specific in this i'm trying to run the next line on java:
convert /home/mohamed.hegab/Desktop/1263392123111.jpg -gamma .45455 -resize 400x400 -gamma 2.2 -quality 92 /home/mohamed.hegab/Desktop/small.jpg
which is run great on the bash command line
but when i run it on the java using process builder it gives me strange result.
public static void resizeImage(String srcPath, String destPath,String size) {
ProcessBuilder pb = new ProcessBuilder("convert", srcPath , " -gamma", ".45455",
" -resize",size, " -gamma ", "2.2", " -quality",
"92" , destPath);
pb.redirectErrorStream(true);
InputStreamReader isr = null;
BufferedReader br = null;
try {
Process p = pb.start();
p.waitFor();
isr = new InputStreamReader(p.getInputStream());
br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (Exception e) {
LOG.error("Exception while trying to convert text to image", e);
} finally {
try {
if(isr != null) {
isr.close();
}
if(br != null) {
br.close();
}
} catch (IOException e) {
LOG.error("Could not close stream", e);
}
}
}
the line that comes in the system.out is strange and weird it says that
convert: unable to open image -gamma': No such file or directory @ blob.c/OpenBlob/2439.
.45455': No such file or directory @ blob.c/OpenBlob/2439.
convert: unable to open image
convert: unable to open image -resize': No such file or directory @ blob.c/OpenBlob/2439.
400x400': No such file or directory @ blob.c/OpenBlob/2439.
convert: unable to open image
convert: unable to open image -gamma ': No such file or directory @ blob.c/OpenBlob/2439.
2.2': No such file or directory @ blob.c/OpenBlob/2439.
convert: unable to open image
convert: unable to open image -quality': No such file or directory @ blob.c/OpenBlob/2439.
92': No such file or directory @ blob.c/OpenBlob/2439.
convert: unable to open image
but the images is comes out only with the size 960 *960 which i don't know where it comes from .
so can any one help me in this :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
避免
-
之前的空格,shell 命令只能识别以-
开头的选项。Avoid the blanks before the
-
, shell commands can only recognize options that start with-
.答案在此链接
http:// www.darcynorman.net/2005/03/15/jai-vs-imagemagick-image-resizing/
只是我应该将命令切成数组中的片段并在没有进程生成器的情况下正常运行它
the answer is here in this link
http://www.darcynorman.net/2005/03/15/jai-vs-imagemagick-image-resizing/
simply i should cut the command to pieces in array and run it normally without process builder