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
when i use simply
convert.run(img,new Object[]{input,output});
i gotjava.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.