Question

I have all eps files as input and these eps files are present in my xml file.

<?xml>
<FIGURE>
    <L-GRAPHIC L="DE">
        <GRAPHIC FILENAME="abc.eps">
        </GRAPHIC>
    </L-GRAPHIC>
</FIGURE>
</xml>

Java code usign ImageMagick

public static void main(String[] args) {
    String inputfileName = "C:\\abc.eps"; 

    try {
        System.out.println("Started" + inputfileName);
        ImageInfo info = new ImageInfo(inputfileName);

        MagickImage magick_converter = new MagickImage(info);

        String outputfile = "C:\\abc.svg"; // Output File name
        magick_converter.setFileName(outputfile);

        magick_converter.writeImage(info);
        System.out.println("Complete");

    } catch (MagickException e1) {          
        e1.printStackTrace();
    } 
}

Current output with above code:

Started

Nothing happens after that.

Please help.

Was it helpful?

Solution

Disclaimer

The ImageMagick solutions does not create vector outputs but pixel file formats. It might solve the problem though. The only, open source, way, I found, to create a svg image from eps is the Inkscape method mentioned briefly below.

EDIT: @Chai has found a solution by himself, see elsewhere on this page.

Manual pre-process

With the open source utility software ImageMagick you can easily convert from one image format to another. In its easiest form just do:

convert image.eps image.png

With use of switches you can tweak the quality and a lot of other features as well.

With the open source drawing software Inkscape you can do the same manually. Simply open the eps image and save it as a svg image file.

Programmatical process

This is one way to solve this using java. The solution is based on the im4java ImageMagick wrapper. In my case there was no need to connect my ImageMagick installation to the java library but if that is the case; how is mentioned on their web-site.

import java.io.IOException;
import org.im4java.core.ConvertCmd;
import org.im4java.core.IM4JavaException;
import org.im4java.core.IMOperation;

public static void main(String[] args) throws IOException, InterruptedException, IM4JavaException {
    ConvertCmd convertCmd = new ConvertCmd();

    IMOperation imOperation = new IMOperation();

    imOperation.addImage("/home/user/images/image.eps");
    imOperation.addImage("/home/user/images/image.png");

    convertCmd.run(imOperation);
}

The pom.xml if you are using maven

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>lab</groupId>
    <artifactId>imagemagick</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.im4java</groupId>
            <artifactId>im4java</artifactId>
            <version>1.4.0</version>
        </dependency>
    </dependencies>
</project>

OTHER TIPS

I have found out the proper solution for this. I used pstoedit.exe and ghostscript to convert eps files to svg format in my java code. Thank you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top