Daniel Warren Daniel is a Java Developer at IDRsolutions and the product manager for FormVu. He enjoys experimenting with different computer systems, D&D, and a variety of PC games.

How to read WMF images in Java

1 min read

WMF icon

What is WMF?

WMFWindows Metafile (WMF for short) is an image file format developed by Microsoft, which has the capabilities for both vector and bitmap images. It is more commonly used for its vector capabilities, similar to a file format such as SVG. Note that once you have loaded a WMF file into a BufferedImage, it has been converted into a bitmap image and is no longer a vector format.

The file name extension for WMF files is: .wmf

Why do WMF Images cause problems for Java Developers?

ImageIO does not support WMF files by default so existing Java Applications will not work with them. This is a problem because WMF is a very common image format for Windows and used for a lot of clip art.

In this post, I will cover how to use JDeli to add WMF support to existing Java Applications which use ImageIO (without having to make any code changes) and how to read WMF images in JDeli directly.

What options are there for reading WMF files in Java?

Java does not read WMF images by default so you will need to use an external library or plugin for ImageIO. JDeli gives pure Java support for WMF files and can also be used as an ImageIO plugin.

If you are looking for a free solution, we recommend the Twelve Monkeys ImageIO plugin GitHub.

In this article we will be using our JDeli pure Java library to read WMF files.

How to upgrade ImageIO to read WMF files

It’s actually very simple and can be done without rewriting your existing code!

For example, the code below does not work with ImageIO for WMF images


Steps to fix with JDeli:

How to read a WMF image in Java directly with JDeli

  1. Add JDeli to your class or module path. (download the trial jar).
  2. Create a File handle, InputStream pointing to the raw WMF image. You can also use a byte[] containing the image data.
  3. Read the WMF image into a BufferedImage

and the Java code to read WMF with JDeli…

Other useful WMF links



Are you a Java Developer working with Image files?

Daniel Warren Daniel is a Java Developer at IDRsolutions and the product manager for FormVu. He enjoys experimenting with different computer systems, D&D, and a variety of PC games.