im4java读了一张图片

时间:2013-06-16 19:13:10

标签: java image im4java

我尝试使用库im4java读取Java中的图像:

File file = new File("img\\test.jpg");
Info imageInfo = new Info(file.getPath(),true);

问题是Info()无法识别图像。称为例外:

Exception in thread "main" org.im4java.core.InfoException: org.im4java.core.CommandException:      java.io.IOException: Cannot run program "identify": CreateProcess error=2, The sistem can not find the specific file.
at org.im4java.core.Info.getBaseInfo(Info.java:360)
at org.im4java.core.Info.<init>(Info.java:151)
at FeatureExtractor.main(FeatureExtractor.java:51)

在路线上,我试图把完整的路线但不起作用。然后我尝试用命令和操作来做,并且不起作用:

    // create command
ConvertCmd cmd = new ConvertCmd();
//cmd.setSearchPath("img");

// create the operation, add images and operators/options
IMOperation op = new IMOperation();
op.addImage("img\\test.jpg");

错误是:

org.im4java.core.CommandException: org.im4java.core.CommandException: Specification not valid.
at org.im4java.core.ImageCommand.run(ImageCommand.java:219)
at FeatureExtractor.main(FeatureExtractor.java:28)

1 个答案:

答案 0 :(得分:0)

您可以设置ImageMagick安装的搜索路径,然后尝试: ProcessStarter.setGlobalSearchPath( “$ PATH:其中;&gt;” 中);