In this November’s release of JDeli, we added EMF and WMF image file support to our Java Image library. In this article, we tell you how to use this exciting new functionality.
JDeli can now read EMF/WMF images directly into Java as a Buffered Image. This can be manipulated in Java and saved out to another file format. JDeli can write BufferedImages to BMP, HEIF, JPEG/JPEG2000, PNG and TIF.
But EMF and WMF are different from other image formats we have added because they are vector graphics. So we have added some additional features to convert them to SVG.
Now you can read on and find out how to read, write and convert EMF and WMF files in just a couple of lines of code with JDeli.
How to read a WMF file in Java
WmfDecoder decoder = new WmfDecoder(); BufferedImage input = decoder.read(new File("path2inputfile.wmf"));
How to read an EMF file in Java
EmfDecoder emfDecoder = new EmfDecoder(); BufferedImage input = decoder.read(new File("inputfile.emf"));
You can use the JDeli WmfDecoder or EmfDecoder directly and convert to SVG using a JDeli method:
How to convert EMF to SVG in Java
EmfDecoder.toSVG(new File("infile.emf"),new File("outfile.svg"));
How to convert WMF to SVG in Java
WmfDecoder.toSVG(new File("infile.wmf"),new File("outfile.svg"));
Why use JDeli?
JDeli offers a range of advantages over ImageIO and alternatives, including:
- prevents heap related JVM crashes
- implements unsupported image formats
- reduce the output file size
- improve read/write performance
- supports threading
- superior image scaling algorithms