I downloaded the library for working with EPS files here.
And wrote some code to parse EPS file:
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);
My code crashes and saying:
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)
Can you help me please?
UPDATED:
When I try to install jmagick, but when I run the command:
./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
Get this error:
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
UPDATED:
I fix it! Just change command to:
./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/
Then I tried:
make all
And get error:
make1: 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
Can somebody help with new error?
I suggest you contact the author of this code or look at the code yourself to figure out why this exception is occurring.
As an alternative there seems to be a number of EPS APIs available for Java. Here are a few:
Also, ImageMagick (a C library) supports EPS to read EPS, and there's a JNI wrapper for ImageMagick called JMagick that allows access to ImageMagick from Java.