Introduction
A Windows Metafile is a recording of drawing commands from the 16-bit Windows graphics system (GDI). Playing the file back draws the picture again: lines, shapes, text and bitmaps, at whatever size is needed. It can hold vector drawing, bitmaps or both.
WMF was the usual way to move clip art and charts between Windows programs in the 1990s, and Office documents still embed it. Its 32-bit successor is the Enhanced Metafile (EMF).
Structure
A WMF file is a header followed by records. Each record is its size in 16-bit words (4 bytes), a 2-byte function number naming the GDI call, and that call's parameters. All numbers are little-endian. The last record is an end-of-file record of three words with function number 0.
Many files start with an extra 22-byte "placeable" header, added by Aldus, that gives
the picture's bounding box and its units per inch. It begins with the key
D7 CD C6 9A. The standard 18-byte header comes after it, or first in a
file without it.
0Placeable header optional, keyD7 CD C6 9A, bounds, units per inch22 bytes22Header type, header size, version, file size, object count18 bytes40Records size, function number, parametersvaries…End of file record03 00 00 00 00 006 bytes
The full layout is in the reference pages: the header, every record, and the objects and code values.
Not described
The header, records and codes pages follow Microsoft’s MS-WMF (23 April 2024),
with some constants from Wine’s wingdi.h.
Known, not yet covered
- Reference: the layouts of the Palette and Region objects and of the sub-structures of each escape record are in MS-WMF but not on the pages.
- Reference: the full 256-entry ternary raster-operation table,
GamutMappingIntent,LogicalColorSpaceandLogicalColorSpaceV5, the PostScript cap, clipping, join and feature enumerations,PaletteEntryFlagandBitCountare in MS-WMF and not listed. - Reference: hatch, mix, fill, stretch, colour usage, flood fill, compression, text alignment,
ExtTextOutand font values were taken from Wine’swingdi.h, not from the MS-WMF enumeration pages, and have not been compared with them. - Viewer: there is no WMF plugin yet.
Links
Software
- LibreOffice – free office suite that opens and exports WMF (Windows, macOS, Linux)
- Inkscape – free vector editor that imports and exports WMF (Windows, macOS, Linux)
- Microsoft Word and PowerPoint – insert WMF pictures into documents (Windows, macOS)
- IrfanView – free image viewer that shows WMF files (Windows)
- XnView MP – image viewer and converter that opens WMF (Windows, macOS, Linux)
Reference
- [MS-WMF]: Windows Metafile Format – Microsoft’s published specification