我在这里下载了用于处理EPS文件的库。
并编写了一些解析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);
我的代码崩溃并说:
线程"main"javax.imageio.IIO异常:不支持数据类型-1位于epsLib.EPSImageReader.readHeader(EPSImageReader.java:307)位于epsLib.EPSImageReader.getHeight(EPSImageReader.java:148)在Main.Main(Main.java:39)在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)位于java.lang.reflect.Method.ioke(Method.java:597)网址: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
获取此错误:
正在检查MagickCore配置/usr/local/Cellar/imagemagick/6.8.0-10/bin/MagickCore-config/usr/local/Cellar/imagemagick/6.8.0-10/bin/MagickCore-config:行50:pkg配置:找不到命令/usr/local/Cellar/imagemagick/6.8.0-10/bin/MagickCore-config:行53:pkg配置:找不到命令/usr/local/Cellar/imagemagick/6.8.0-10/bin/MagickCore-config:第47行:pkg配置:找不到命令正在检查magik/api.h的可用性。。。不正在检查magik/api.h的存在。。。不正在检查magik/api.h…否configure:error:找不到ImageMagick头文件
更新:
我修好了!只需将命令更改为:
./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
并得到错误:
make1:正在进入目录
/Users/olegsuzaev/jmagick-6.4.0/src'make[2]: Entering directory
/Users/olegsuzaev/jmagick-6.4.0/src/magick'../../Make.rules:175:*缺少分隔符。停止make[2]:离开目录/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]错误2
有人能帮助解决新的错误吗?
我建议您联系此代码的作者或亲自查看代码,以找出发生此异常的原因。
作为一种替代方案,似乎有许多可用于Java的EPS API。以下是一些:
- jlibeps
- EPS图形API
- 起重臂EPS
- Java EPS图形
此外,ImageMagick(一个C库)支持EPS读取EPS,并且有一个名为JMagick的ImageMagick的JNI包装器,允许从Java访问ImageMagick。