Mac 下 GraphicsMagick + im4java 获取图片信息问题
这个是 im4java
http://im4java.sourceforge.net/docs/dev-guide.html 文档
以下是官方使用说明
Image Information
Info imageInfo = new Info(filename,true);
System.out.println("Format: " + imageInfo.getImageFormat());
System.out.println("Width: " + imageInfo.getImageWidth());
System.out.println("Height: " + imageInfo.getImageHeight());
System.out.println("Geometry: " + imageInfo.getImageGeometry());
System.out.println("Depth: " + imageInfo.getImageDepth());
System.out.println("Class: " + imageInfo.getImageClass());
在 Mac 下 GraphicsMagick + im4java 获取图片信息问题
package me.dengtao.test;
import java.io.File;
import org.im4java.core.Info;
public class AllTest {
public static int w(String filename) {
try {
Info imageInfo = new Info(filename, true);
System.out.println("Format: " + imageInfo.getImageFormat());
System.out.println("Width: " + imageInfo.getImageWidth());
System.out.println("Height: " + imageInfo.getImageHeight());
System.out.println("Geometry: " + imageInfo.getImageGeometry());
System.out.println("Depth: " + imageInfo.getImageDepth());
System.out.println("Class: " + imageInfo.getImageClass());
return 0;
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
public static void main(String[] args) {
String filename = "/Users/dengtao/Downloads/1.jpg";
File file = new File(filename);
System.out.println(file.exists());
w(filename);
}
}
运行后面错误
true
org.im4java.core.InfoException: org.im4java.core.CommandException: java.io.IOException: Cannot run program "identify": error=2, No such file or directory
at org.im4java.core.Info.getBaseInfo(Info.java:360)
at org.im4java.core.Info.<init>(Info.java:151)
at me.dengtao.test.AllTest.w(AllTest.java:11)
at me.dengtao.test.AllTest.main(AllTest.java:33)
Caused by: org.im4java.core.CommandException: java.io.IOException: Cannot run program "identify": error=2, No such file or directory
at org.im4java.core.ImageCommand.run(ImageCommand.java:219)
at org.im4java.core.Info.getBaseInfo(Info.java:342)
... 3 more
Caused by: java.io.IOException: Cannot run program "identify": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
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)
... 4 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:248)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 7 more
提示应该是文件不存在,可
File file = new File(filename);
System.out.println(file.exists());
确实存在
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
后来呢,怎么解决了,能给个提示吗,我也碰到这个问题 ,烦劳给个邮件 andy222241#企鹅.com