我下载了库以处理EPS文件here
并编写一些代码来解析eps文件
EPSImageReaderSPI spi = new EPSImageReaderSPI();
EPSImageReader eps = new EPSImageReader(spi);
File file = new File("file.eps");
InputStream in = null;
try {
in = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageInputStream iis = null;
iis = ImageIO.createImageInputStream(in);
eps.setInput(iis);
eps.getHeight(0);
我的代码崩溃了
Exception in thread "main" javax.imageio.IIOException: Data type -1 not supported
at epsLib.EPSImageReader.readHeader(EPSImageReader.java:307)
at epsLib.EPSImageReader.getHeight(EPSImageReader.java:148)
at Main.main(Main.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
你可以帮帮我吗?
非常感谢!
更新:
当我尝试安装jmagick时,但是当我运行命令时
./configure --with-java-home=/System/Library/Frameworks/JavaVM.framework/Versions/Current --with-magick-home=/usr/local/Cellar/imagemagick/6.8.0-10 --with-magick-inc-dir=/usr/local/Cellar/imagemagick/6.8.0-10/include
得到错误
checking for MagickCore-config... /usr/local/Cellar/imagemagick/6.8.0-10/bin/MagickCore-config
/usr/local/Cellar/imagemagick/6.8.0-10/bin/MagickCore-config: line 50: pkg-config: command not found
/usr/local/Cellar/imagemagick/6.8.0-10/bin/MagickCore-config: line 53: pkg-config: command not found
/usr/local/Cellar/imagemagick/6.8.0-10/bin/MagickCore-config: line 47: pkg-config: command not found
checking magick/api.h usability... no
checking magick/api.h presence... no
checking for magick/api.h... no
configure: error: Unable to find ImageMagick header files
更新:
好的我修好了! 只需将命令改为
./configure --with-java-home=/System/Library/Frameworks/JavaVM.framework/Versions/Current --with-magick-home=/usr/local/Cellar/imagemagick/6.8.0-10 --with-magick-inc-dir=/usr/local/Cellar/imagemagick/6.8.0-10/include/ImageMagick/
然后我尝试
make all
并收到错误
make[1]: Entering directory `/Users/olegsuzaev/jmagick-6.4.0/src'make[2]: Entering directory `/Users/olegsuzaev/jmagick-6.4.0/src/magick'../../Make.rules:175: *** missing separator. Stop.
make[2]: Leaving directory `/Users/olegsuzaev/jmagick-6.4.0/src/magick'
make[1]: *** [dir_target] Error 2
make[1]: Leaving directory `/Users/olegsuzaev/jmagick-6.4.0/src'
make: *** [dir_target] Error 2
有人可以帮忙吗? THX
答案 0 :(得分:2)
我建议您联系此代码的作者或亲自查看代码,找出发生此异常的原因。
作为替代方案,似乎有许多可用于Java的EPS API。以下是一些:
此外,ImageMagick(一个C库)支持EPS读取EPS,还有一个名为JMagick的ImageMagick JNI包装器,允许从Java访问ImageMagick。