Nirali Nirali is a Java Developer at IDR Solutions and also enjoys being part of the business development team. She is currently studying for her MSc Computing at De Montfort University.

How to read and write EMF and WMF files in Java?

1 min read

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

Learn more about JDeli, or download it to try it yourself.

Nirali Nirali is a Java Developer at IDR Solutions and also enjoys being part of the business development team. She is currently studying for her MSc Computing at De Montfort University.

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2019. All rights reserved.