Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emf to jpg conversion

My objective is to convert emf,wmf file formats to other image file formats.

I included image4java jar and tried to convert my emf file to other formats like jpg,png.. using the following code:

import org.im4java.core.ConvertCmd;
import org.im4java.core.IMOperation;
import java.io.File;
public class im4java {
    public static void main(String arg[])
    {
        File input=new File("src/image.emf");
        File output=new File("src/output.jpg");
        convertemf2png(input,output);
    }
    public static void convertemf2png(File input,File output)
    {
        try{
        IMOperation img=new IMOperation();
        img.addImage();
        img.addImage();
        ConvertCmd convert=new ConvertCmd();
        convert.run(img,new Object[]{input,output});
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}

while i execute it, i got the error like

  1. when i use simply convert.run(img,new Object[]{input,output}); i got

    java.lang.IllegalArgumentException: java.io.File is an unsupported image-type

            at org.im4java.core.ImageCommand.resolveImages(ImageCommand.java:289)
            at org.im4java.core.ImageCommand.prepareArguments(ImageCommand.java:189)
            at org.im4java.core.ImageCommand.run(ImageCommand.java:208)
            at im4java.convertemf2png(im4java.java:27)
            at im4java.main(im4java.java:18)
    

when i use, `convert.run(img,new Object[]{input.getAbsolutePath(),output.getAbsolutePath()}); i got,

 org.im4java.core.CommandException: org.im4java.core.CommandException: Invalid Parameter - C:\vignesh\im4java\src\output.jpg
        at org.im4java.core.ImageCommand.run(ImageCommand.java:215)
        at im4java.convertemf2png(im4java.java:27)
        at im4java.main(im4java.java:18)
Caused by: org.im4java.core.CommandException: Invalid Parameter - C:\vignesh\im4java\src\output.jpg
        at org.im4java.core.ImageCommand.finished(ImageCommand.java:247)
        at org.im4java.process.ProcessStarter.run(ProcessStarter.java:314)
        at org.im4java.core.ImageCommand.run(ImageCommand.java:211)

anyone please help me in fizing this issue or any other way to convert emf formatt image to other formats..Thanks in advance.

like image 229
vignesh Avatar asked Feb 08 '11 06:02

vignesh


1 Answers

You need to set the path to the ImageMagic executable - you are inadvertently calling a windows program named convert

like image 169
rhollencamp Avatar answered Sep 19 '22 12:09

rhollencamp