Windows Metafile FAQ
Last Updated: August 1, 2024
Introduction
Here are some answers to frequently asked questions about Windows metafiles. If your question isn’t answered here, please send it to Support@CompanionSoftware.com for possible inclusion in the next update of this document.
NOTE: External sites are not necessarily endorsed by Companion Software.
Table of Contents
Within this document, you will find information about:
- The Basics
- Converting Between Formats
- Clip Art
- Importing and Editing
- Browser Support
- Internal Structure
- Vulnerabilities and Exploits
- Viewers
The Basics
What is a graphic?
For the purpose of our discussion, a graphic is any kind of image displayed by a computer. This includes vector graphics and raster graphics.
What is a vector graphic?
A vector graphic is a graphic drawn as lines, polygons and text. It can be something simple like this:
or more complex like this:
What is a raster graphic?
A raster graphic is a graphic drawn as an array of colored dots. A typical raster graphic is a photograph such as this:
If you look closely at the image, you will see that it is actually comprised of many colored dots (pixels):
What is a metafile?
A metafile is a list of commands that can be played back to draw a graphic. Typically, a metafile is made up of commands to draw objects such as lines, polygons and text and commands to control the style of these objects. NOTE: Some people equate metafiles with vector graphics. In most cases this is fine; but, strictly speaking, a metafile can contain any mix of vector and raster graphics. For example, a metafile could contain just one command to display a bitmap! Unless the distinction is important, we will consider a metafile to be a kind of vector graphic in this FAQ.
What is a picture?
In the Windows world, picture is the generic, user-friendly name for a metafile.
What is a bitmap?
A bitmap is a another name for a raster graphic. In Windows, these are typically saved in a BMP file. However other common bitmap formats include GIF, JPEG and PNG.
What are the tradeoffs between vector (metafile) and raster (bitmap) graphics?
In general, vector graphics take longer to display but can be scaled to any size with no degradation. Raster graphics are faster to display but image quality suffers when they are scaled up or down. Here is a small picture
that is saved as a bitmap and then scaled up to a larger size:
Here is the same picture scaled up as a vector graphic:
Also, there is a tradeoff between the size of a graphic and its complexity. The vector graphic file needed to draw a cross-hatched rectangle full page on a 600-DPI laser printer might be just a few hundred bytes; the comparable raster graphic might be a thousand times bigger! On the other hand, the vector graphic file needed to draw a detailed engineering drawing in a one inch square could be thousands of times bigger than the corresponding raster graphic. So you can’t say vector graphics are smaller than raster graphics or vice versa. It depends on the graphic!
What is a Windows metafile (WMF file)?
A Windows metafile is a 16-bit metafile that can be used by 16- and 32-bit versions of Microsoft Windows (3, 95, 98, Me, NT, 2000, XP and Vista) to display a picture.
What is an enhanced metafile (EMF file)?
An enhanced metafile is a 32-bit metafile that can be used by 32-bit versions of Windows (95, 98, Me, NT, 2000, XP and Vista) to display a picture. An enhanced metafile can contain a much broader variety of commands than a “regular” Windows metafile. Basically, the enhanced metafile format is a 32-bit super-set of the 16-bit Windows metafile format.
How do Windows clipboard files (CLP files) relate to Windows metafiles?
A CLP file can simultaneously contain a graphic in Picture (WMF), Enhanced metafile (EMF), Bitmap (BMP) and other formats. Some programs (such as Metafile Companion) can extract these files from a CLP file.
Do Windows metafiles support the CMYK color space?
No. Windows metafiles are basically recordings of Windows graphics commands. Windows GDI (Graphics Device Interface) solely uses an RGB color model, so any CMYK document/picture (e.g. from Adobe Illustrator) when saved as an EMF (or WMF) file would lose any CMYK information.
If you plan to import the picture into another application that does support CMYK, consider using an intermediate format that does support CMYK (such as EPS, TIFF or JPEG) that is supported by the importing application.
What are some of the less-than-obvious limitations of Windows metafiles?
Here are a few limitations of metafiles (Windows metafiles (WMF) and/or enhanced metafiles (EMF), as noted) that you might not expect:
- Metafiles don’t support embedded fonts. This means that if you use a “special” font in a metafile that font won’t be displayed on other systems if they don’t have that font installed.
- Metafiles don’t have any concept of text paragraphs, word wrapping, multiple fonts per string, etc. Each piece of text must have the same font. Layout is done by individually placing individual text objects.
- There is no arrow primitive or any other built-in shapes other than lines, rectangles, ellipses, polylines and polygons. Other objects are built up from these primitives.
- Windows metafiles (WMF) don’t support rotation of objects in general. Text can be rotated in WMF files.
- Windows metafiles (WMF) don’t support wide linetypes other than solid.
- Windows metafiles (WMF) don’t have any concept of a gradient fill. If you see a gradient fill in a Windows metafile, it is composed of many polygons or other objects.
Converting Between Formats
Can I convert a WMF file to an EMF file?
Yes. But there is no compelling reason to do this that I can think of. As of this writing, most Windows programs both WMF and EMF files directly. However, if you’re really interested in doing the conversion, keep reading…
If you’re a programmer, 32-bit versions of Windows can automatically convert between WMF and EMF files. See the Win32 documentation on the SetWinMetaFileBits() and GetWinMetaFileBits() functions for more details.
Mere mortals can use any number of image conversion programs to convert between formats. For more details, see the Graphics Conversion Software section of the Companion Software Other Helpful Web Sites page.
Can I convert an EMF file to a WMF file?
Yes. The best reason to do this is you need to use the file in a program that doesn’t support EMF files. But beware! The WMF format is a subset of EMF format so you may lose some information when doing the conversion.
If you’re a programmer, 32-bit versions of Windows can automatically convert between WMF and EMF files. See the Win32 documentation on the SetWinMetaFileBits() and GetWinMetaFileBits() functions for more details.
Mere mortals can use any number of image conversion programs to convert between formats. For more details, see the Graphics Conversion Software section of the Companion Software Other Helpful Web Sites page.
How can I convert a WMF (or EMF) file to PNG, GIF or JPEG format for use on my Web page?
First, you should strongly consider converting it to an SVG (Scalable Vector Graphics) file instead of a web bitmap format such as PNG, GIF or JPEG! Metafiles are primarily a vector format and resolution-independent; so are SVG files. Bitmaps only look good at one specific size.
You can find links to a number of Windows conversion programs at the Graphics Conversion Software section of the Companion Software Other Helpful Web Sites page.
If you have a recent version of Office, you can open metafiles with the Microsoft Office Picture Manager and then save them in the format you want with the File > Export command. Another strategy is to create a Microsoft Word document containing the WMF (or EMF) file(s) and then save it as HTML; this converts metafiles and other graphics files in the document to GIF files. You can also use Metafile Companion from Companion Software to copy the metafile to the clipboard, paste it to Windows Paint and then save it in the desired format.
As a rule of thumb, use PNG or GIF for line art, clip art, etc. and use JPEG for continuous-tone images (photographs).
How can I convert a WMF or EMF file to an SVG (Scalable Vector Graphics) file for use on my Web page?
For the web, you definitely want to use the SVG (Scalable Vector Graphics) format. It is a web standard supported by all modern browsers and “vector” is literally its middle name. Metafiles are inherently a vector format (at least as produced by Metafile Companion) and are therefore resolution independent. Web bitmap formats (e.g. PNG, JPEG and GIF) are resolution-dependent and only look their best at one specific size.
A Google search for “convert emf to svg” turns up a number of sites that can do the conversion online.
How can I convert a BMP file to a WMF file?
Beware! There are two types of conversions that can be performed and they are very different.
Most conversion programs convert a BMP to a WMF file by simply putting the bitmap in a metafile “shell”. The resulting WMF file is still essentially the same original bitmap and gives you no particular advantage over the original BMP file. And this kind of “bitmap disguised as a WMF file” cannot be edited by Metafile Companion. For more details, see the Graphics Conversion Software section of the Companion Software Other Helpful Web Sites page.
However, some conversion programs “auto-trace” or “vectorize” the bitmap converting areas of color to lines and polygons which are then stored in the WMF file. These WMF files can be edited by Metafile Companion. If this is the kind of conversion you want, check out Adobe Illustrator from Adobe. It may to be able to trace bitmaps.
Can a Windows bitmap (BMP) file be transparent in some areas (like a GIF file)?
No. The Windows bitmap format does not support the idea of transparency. However, the Windows metafile format does (see the next question).
Can I convert a Windows bitmap (BMP) file into a transparent Windows metafile (WMF)?
In theory, yes. In practice, we are still looking for a good way to do this.
Basically, there are two approaches you can take:
- Put the bitmap in a metafile along with a transparency mask bitmap and use the proper bitmap operations to apply the mask to the bitmap before displaying it on the screen, or
- Convert the bitmap to a metafile by “vectorizing” it (as described above) and then delete all objects of the background color.
I don’t know of any program that can do approach number 1. You can do approach number 2 by using one of the vectorizing programs described above to convert from bitmap to metafile format. Then use a program like Metafile Companion to select and delete all the background color objects.
Clip Art
Should I get clip art in vector (metafile) or raster (bitmap) format?
The rule of thumb is, get clip art in the form it was created. For most clip art, this means getting it in a vector format (Windows metafile, EPS file, etc.). In vector format, clip art can be scaled to any size you want without loss of quality. However, if the original graphic was a photograph (continuous-tone image) that was scanned in as a raster graphic (bitmap, BMP, GIF, JPEG, PNG, etc.), then get the bitmap format.
Where can I find vector format (WMF/EMF) clip art?
A variety of vendors offer clip art in WMF format. A good place to start is with a Google search for “wmf clipart”.
How can I edit my vector format (WMF/EMF) clip art?
Most modern Windows drawing programs (such as Microsoft PowerPoint, Adobe Illustrator, etc.) can import and edit Windows metafiles. However, most have their limitations and idiosyncracies. The one program that was designed just to edit WMF files is Metafile Companion.
Importing and Editing
Why does my metafile “change” in some programs when I import it?
Often, drawing programs import a metafile by reading it and converting each metafile object to the closest corresponding drawing object. No drawing program that I am aware of supports all the possible objects contained in a Windows metafile. And some don’t always draw objects the same way Windows does.
Most often drawing programs don’t handle things like PolyPolygons (polygons with holes and islands), rotated text, bitmap fill patterns and transparent hatch patterns. This can cause certain “idiosyncracies” to appear when editing some metafiles.
If you want to put your favorite drawing program to the test, use it to open TEST.WMF, and make a small change to one of the objects (to make sure the metafile has really been converted to the drawing program’s native format). Then use the Windows Clipboard Viewer to open TEST.CLP and see what the chart should really look like! Are they the same? (They are if you’re using Metafile Companion!)
Why do some programs display a metafile properly when it is imported, but then change it when I edit it?
This is related to the previous question. Basically, any Windows program can accurately display a Windows metafile with a few lines of code. They just hand the metafile to Windows and say “display it”. So some drawing programs take the following approach with metafiles. Initially, when the metafile is added they display it “as is”. But as soon as the user tries to edit (or ungroup) the metafile, then they convert it to their own internal format and that’s where the idiosyncracies occur.
Are there any drawing programs that can edit a metafile without changing it?
Metafile Companion from Companion Software is a pretty good metafile editor. But even it doesn’t support every metafile command.
Browser Support
Can I use WMF or EMF graphics in my web pages?
Browsers don’t support viewing WMF or EMF files directly like they do GIF, JPEG and PNG. The Scalable Vector Graphics (SVG) standard is the true “metafile for the Web” and has universal support in modern browsers on smartphones, tablets, laptops and desktop computers. So convert your metafiles to SVG files and then use the SVG files on the web.
Internal Structure
Where can I find information about the internal structure of Windows metafiles (WMF files) and enhanced metafiles (EMF files)?
The first place to check is the Microsoft Developer Network site since Microsoft created these file formats. Microsoft has published the specifications:
Another great resource is the now out-of-print Encyclopedia of Graphics File Formats from O’Reilly.
You might also want to check out Windows Metafiles – a guide for non-windows programmers.
Where can I find information about the internal structure of Windows clipboard files (CLP files)?
On the Microsoft Developer Network. (Déja vû all over again.)
The Encyclopedia of Graphics File Formats (mentioned above) also has information about the CLP file format.
How can I list the records inside a particular metafile?
On the Microsoft Developer Network site, there are a couple of sample Windows programs called WMFDCODE and EMFDCODE that can display a metafile and list its contents.
Other utilities to list the contents of metafiles can be found at the Metafile Listing Utilities section of the Companion Software Windows Metafile Resource Center.
How can I compare two metafiles to see if they are equivalent?
You could compare two metafiles using the DOS COMP or FC command. However, this doesn’t always work. Sometimes, metafiles produce identical output but have random “garbage” bytes in unused portions of the file. Other times they contain a “comment” record that includes the filename or other information that doesn’t affect the actual output. So, for example, if you open one WMF file (with a program like Metafile Companion), save it with a new name and then do a “binary” compare of the files, the two files won’t compare.
The answer to these problems is to do a “conceptual compare” of the actual metafile records themselves excluding any comments. A simple way to to this is to do a binary compare of the listings of two metafiles.
Utilities to compare the listings of metafiles can be found at the Metafile Compare Utilities section of the Companion Software Windows Metafile Resource Center.
Vulnerabilities and Exploits
Is it true that just viewing a WMF file could allow someone to take over my machine?
The short answer is “yes, on older versions of Windows”. For all the details, see Microsoft Security Bulletin MS06-001: Vulnerability in Graphics Rendering Engine Could Allow Remote Code Execution. However, this is no longer a problem for Windows XP Service Pack 2 or later. Also, few if any exploitations of this vulnerability have been reported.
Viewers
Is there a metafile thumbnail viewer for Windows Vista and Windows 7?
In Windows Vista and Windows 7, when you display a folder in thumbnail view, it doesn’t display thumbnails of WMF and EMF files. I haven’t seen any official information about why this is. But my guess is they don’t want to risk triggering any security flaw in the metafile viewer code (see Microsoft Security Bulletin MS06-001: Vulnerability in Graphics Rendering Engine Could Allow Remote Code Execution for example).
If you would like to try a free, third-party program to restore these thumbnails, check out the emfplugin for Windows Explorer.