Fact-checked by Grok 2 weeks ago

Windows Metafile

The Windows Metafile (WMF) is a and graphics developed by for storing images in a device-independent manner within Windows operating systems, consisting of a header followed by an of variable-length records that encode drawing commands and graphics objects. Introduced in the early versions of Windows to support 16-bit applications, WMF enables the recording and playback of graphical output from the Windows (GDI), facilitating tasks such as transfers, printing, and document portability. WMF files are structured as a sequence of metafile , each representing GDI calls like line drawing, filling, text rendering, and handling, which collectively define the image content without embedding pixel data directly. The format includes an optional placeable header for additional , such as bounding coordinates and checksums, but lacks comprehensive details on , palettes, or text descriptions compared to later formats. Due to its origins in 16-bit environments, WMF is - and application-dependent, with playback influenced by mapping modes and resolutions, and it does not support advanced features like curves, paths, or transformations. To address WMF's limitations, introduced the Enhanced Metafile () format in the 32-bit era, which extends WMF with improved device independence, scalable records, and support for modern GDI functions; WMF files can be converted to EMF using API calls like SetWinMetaFileBits. Despite its age, WMF remains relevant for in Windows applications, legacy document processing, and interoperability with tools that handle for plotting or archiving. The specification has undergone multiple revisions, with the latest documented version (18.0) updated as of April 2024, ensuring ongoing support for core functionality in contemporary systems.

Overview

Definition and Purpose

The Windows Metafile (WMF) is a format developed by for storing graphical images as a sequence of variable-length records containing (GDI) drawing commands. These records capture instructions for rendering vector elements, such as lines, polygons, and basic shapes, alongside support for embedded raster bitmaps, aiming for scalable output in a device-independent format, though playback can be influenced by device resolution and mapping modes. In essence, a WMF functions as a of an image, which can be played back to reproduce the original graphics on compatible devices. The primary purpose of the Windows Metafile format is to facilitate device-independent rendering in Windows environments, particularly for output to printers and displays, by allowing applications to record and spool drawing operations without embedding hardware-specific details. This portability ensures that the same set of GDI commands can be executed consistently across varied output contexts, simplifying the transfer of graphical content between applications and systems. Metafiles emerged as a key solution to portability challenges in early GDI-based APIs, where direct device calls risked incompatibility and limited reuse of visual data. The original WMF uses the .wmf file extension, while the enhanced version employs .emf; the standard MIME type for WMF files is image/x-wmf. Over time, the format has evolved into Enhanced Metafile (EMF) and further extensions to enhance device independence and feature support.

Key Formats and Evolution

The Windows Metafile (WMF) format, introduced in 1987 with , serves as the original 16-bit format designed for storing sequences of (GDI) commands in a device-independent manner. It employs 16-bit signed integer coordinates, which restrict the drawable area to a range of -32,768 to 32,767 units, potentially limiting precision and scalability for larger or more detailed images. This format was pivotal in early Windows applications for operations and but suffered from device dependencies and limited color support. To address these shortcomings, developed the Enhanced Metafile (EMF) format in the early 1990s, debuting with in 1993 and via extensions. EMF upgrades to a 32-bit structure, utilizing signed 32-bit integer coordinates for vastly improved precision and a larger addressable space, enabling better scalability across devices. It also incorporates enhanced device independence through bounding rectangles and reference device contexts, while supporting text via records like EMR_EXTTEXTOUTW, facilitating international character handling. Building further on EMF, the Enhanced Metafile Plus (EMF+) format emerged in 2001 with the introduction of GDI+ in , extending the EMF spool to embed GDI+ calls for richer capabilities. EMF+ introduces support for alpha channels in bitmaps and brushes, allowing and effects, as well as fills, brushes, and path-based rendering that emulate advanced features akin to those in modern s. Available in EMF+ Only mode for GDI+-exclusive content or Dual mode for with standard EMF records, it enables high-fidelity playback on systems supporting GDI+. This progression reflects the evolution of Windows graphics: from the rudimentary WMF in the 1980s, constrained by 16-bit architecture; to in the , prioritizing 32-bit scalability and portability; and culminating in EMF+ during the 2000s, which integrates sophisticated rendering for contemporary applications while maintaining .

History

Development of Original WMF

The original Windows Metafile (WMF) format appeared with the release of on December 9, 1987, as a core component of Microsoft's 16-bit Windows operating systems. Developed during the mid-1980s, it formed an integral part of the (GDI), Microsoft's foundational for handling graphics output. The primary design goals centered on enabling device-independent graphics operations, particularly for printing and transfers, by capturing graphical content in a portable manner that minimized information loss during scaling or device changes. At its core, the WMF format was engineered by to record sequences of GDI function calls, such as line drawing, shape filling, and text rendering, into a compact binary structure for later replay on any compatible . This approach allowed applications to store vector-based images and bitmaps in a single file, supporting without and facilitating across Windows environments. The format used the METAFILEPICT structure for integration, enabling seamless copy-paste operations of between programs while preserving editability through GDI playback. An extension known as the placeable metafile header, developed by Aldus Corporation around 1988 for use in PageMaker, added metadata like bounding rectangles and became widely adopted for improved portability. Despite its innovations, the original WMF suffered from key limitations inherent to its 16-bit architecture, including the use of 16-bit integer coordinates that restricted image dimensions to a maximum of 16,383 units in each direction, leading to precision loss and distortion when scaling to high-resolution displays or printers. Additionally, the initial version (METAVERSION100) lacked support for device-independent bitmaps (DIBs) and advanced font technologies, such as TrueType fonts—which were not introduced until 1991—resulting in reliance on device-specific rasterization for text and limited portability across font environments. These constraints made WMF suitable primarily for simple 2D graphics but inadequate for complex or high-fidelity applications, prompting later enhancements like the Enhanced Metafile (EMF) to address such shortcomings. With Windows 3.0 in 1990, the format was updated to METAVERSION300, adding DIB support for better device independence. Early adoption of WMF was driven by its native integration into Windows applications, particularly Microsoft's productivity tools, where it served as a standard format for embedding and exchanging in documents. This widespread use in early Windows ecosystems solidified WMF's role, despite its technical constraints.

Introduction of Enhanced Formats

The Enhanced Metafile () format was introduced in 1993 as part of the Win32 API with the release of , serving as a 32-bit successor to the original Windows Metafile (WMF) to overcome its 16-bit limitations in coordinate precision and device independence. EMF employs 32-bit fixed-point coordinates for improved accuracy in rendering scalable graphics across diverse display resolutions and devices, while also supporting long filenames through its enhanced file structure. This format played a central role in the Win32 (GDI), enabling developers to create portable, device-independent pictures that could be played back consistently via functions like CreateEnhMetaFile. Building on EMF, the Enhanced Metafile Plus (EMF+) format emerged in 2001 alongside the GDI+ library in , extending the EMF structure to incorporate advanced graphics features not feasible in the base format. EMF+ introduced support for cubic Bézier curves through records like EmfPlusDrawBeziers, enabling smoother path rendering, along with variable (alpha blending) for more realistic compositions and optional of records to reduce file sizes and improve efficiency. These enhancements addressed WMF's scalability challenges, such as imprecise rendering on high-DPI displays, by leveraging EMF's foundation for better fidelity and extensibility. EMF+ achieved deeper integration with the .NET Framework by embedding GDI+ commands as private data within EMF comment records (e.g., EMR_COMMENT_EMFPLUS), allowing seamless playback in managed code environments without disrupting legacy EMF compatibility. This milestone facilitated the transition to modern graphics programming in Windows applications, prioritizing device independence and performance for evolving display technologies.

Technical Structure

WMF Format Details

The original Windows Metafile (WMF) format is a structure consisting of a fixed header followed by a sequence of variable-length that encode graphics commands and objects. The core header, known as the META_HEADER , spans 9 words (18 bytes) and provides essential about the file. This header begins immediately after any optional placeable extension and is always the first required in the metafile. The META_HEADER structure is defined as follows:
FieldSize (bytes)TypeDescription
Type2WORD (16-bit unsigned)Specifies the metafile type; value 0x0001 indicates a WMF.
HeaderSize2WORD (16-bit unsigned)Number of words in the header; always 9 for WMFs.
Version2WORD (16-bit unsigned)Metafile version; for example, 0x0300 corresponds to the implementation.
SizeLow2WORD (16-bit unsigned)Low-order word of the total file size in words.
SizeHigh2WORD (16-bit unsigned)High-order word of the total file size in words (combined with SizeLow to form a 32-bit value).
NumberOfObjects2WORD (16-bit unsigned)Number of objects (such as brushes or pens) defined in the metafile.
MaxRecord4DWORD (32-bit unsigned)Size of the largest record in the file, measured in words.
NumberOfMembers2WORD (16-bit unsigned)Reserved field; must be 0x0000 and is unused.
Following the META_HEADER, the metafile may include a logical palette defined through dedicated records, such as META_CREATEPALETTE or META_SETPALENTRIES, which map colors using RGB values and flags for device-independent rendering. The body of the WMF consists of variable-length records, each beginning with a 4-byte RecordSize field (specifying the total size in words, including headers) followed by a 2-byte RecordFunction field that identifies the operation (e.g., drawing or object creation). The remaining bytes contain parameters specific to the function, often padded to align on word boundaries, with the sequence of records bounded by the META_EOF record (RecordFunction 0x0000, RecordSize 3 words). Coordinates in WMF records use 16-bit signed integers (SHORT type) to represent positions in device units, with the origin at the upper-left corner of the and the positive y-axis directed downward; this system defaults to MM_TEXT mapping mode, where one logical unit equals one device pixel. For improved portability, an optional 18-byte META_PLACEABLE header may precede the META_HEADER, extending the format with a (0x9AC6CDD7), a metafile (0x0000 on disk), an 8-byte bounding box in logical units (left, top, right, bottom as 16-bit signed integers), logical inches per physical inch (typically 1440 for twips), reserved bytes (0x00000000), and a 2-byte computed as the XOR of the prior ten 16-bit words to validate integrity. This placeable extension enhances device-independent placement without altering the core WMF structure, which later evolved into the 32-bit Enhanced Metafile () format for broader capabilities.

EMF Format Details

The Enhanced Metafile () format represents a significant advancement over its predecessor, the Windows Metafile (WMF), by adopting a 32-bit that enables greater precision and portability in graphical representations. Unlike the 16-bit WMF, EMF records utilize 32-bit integer coordinates for logical units, supporting larger canvases and finer detail without device-specific dependencies. This structure facilitates device-independent rendering, making EMF suitable for applications ranging from screen display to high-resolution printing. The EMF file commences with the EMR_HEADER record (type 1), which establishes the metafile's foundational parameters in a structured binary format. The record begins with an 8-byte prefix common to all EMF records: a 32-bit unsigned integer for the type (EMR_HEADER = 0x00000001) and a 32-bit unsigned integer for the total record size in bytes. Following this prefix, the core header includes the rclBounds field (a RECTL structure specifying the smallest rectangle enclosing the image in logical units, inclusive-inclusive coordinates) and the rclFrame field (a RECTL structure specifying the reference device frame in 0.01 mm units, inclusive-inclusive coordinates), the device frame dimensions via the szlDevice field (a SIZEL structure in pixels), the millimeter units via the szlMillimeters field (a SIZEL structure also in 0.01 mm units, equivalent to 100 units per millimeter), and the RecordSignature field (a 32-bit value, ENHMETA_SIGNATURE = 0x464D4520 for standard EMF files). This initial segment culminates at the file offset where the ASCII signature " EMF" (with leading space) appears, confirming the format. The full EMR_HEADER record extends beyond this core with additional fixed fields (such as metafile version, total bytes, and record count) and optional variable-length elements like a description string, totaling up to 108 bytes for the fixed ENHMETAHEADER plus extensions.
FieldTypeSize (bytes)Description
TypeULONG4Record type identifier (1 for EMR_HEADER).
SizeULONG4Total size of the EMR_HEADER record in bytes.
rclBounds (image bounds)RECTL16Smallest rectangle enclosing the metafile picture, in logical units (inclusive-inclusive coordinates).
rclFrame (reference frame)RECTL16Reference device frame enclosing the metafile picture, in 0.01 mm units (inclusive-inclusive coordinates).
szlDevice (device frame)SIZEL8Dimensions of the reference device in pixels (width and height).
szlMillimetersSIZEL8Dimensions of the reference device in 0.01 mm units (width and height, providing 100 units per millimeter for metric scaling).
RecordSignatureULONG4Signature identifying the format (e.g., 0x464D4520).
Subsequent records in the EMF follow the same 8-byte prefix format, with the type indicating the operation (e.g., or change) and the size specifying the length of the ensuing parameters, which can reach up to 2^32 - 1 bytes to accommodate complex graphics. Parameters are tightly packed tailored to the record type, ensuring efficient without beyond necessary . This design allows for a variable number of records, each self-describing its extent, enabling incremental processing during playback or . EMF incorporates several enhancements for robustness and interoperability, including 32-bit signed integer coordinates for logical positions (via structures like POINTL and RECTL), which support extensive ranges far exceeding 16-bit limitations. Text-related records utilize (UTF-16) encoding for strings, promoting global language support over the ANSI limitations of earlier formats. The reference device data in the header—encompassing pixel and millimeter dimensions—enables precise scaling and rendering in modes like MM_TEXT, where output aligns to device-specific metrics without recomputation. An file concludes with the EMR_EOF (type 1), a minimal 8-byte entry signaling the end of records and validating the metafile's integrity; its size field is typically 8 bytes, containing no parameters. The total file size is predetermined by the nBytes field in the EMR_HEADER, allowing verification by summing individual record sizes during . This ensures complete playback without trailing data. EMF's emphasizes with printer spoolers, permitting direct transmission of records to output devices for interpretation without requiring full GDI emulation on the , thus optimizing workflows in Windows environments. This spooler-friendly approach reduces latency in rendering pipelines while maintaining the format's device independence.

EMF+ Format Details

EMF+ metafiles maintain compatibility with the EMF format by beginning with a standard EMF header record, immediately followed by an EMR_COMMENT_EMFPLUS record that signals the presence of embedded EMF+ data. This comment record uses the identifier 0x2B464D45, representing the ASCII string "EMF+" in little-endian format, to identify the subsequent data as EMF+ private content. The EMF+ private records reside within the CommentRecordBuffer of the EMR_COMMENT_EMFPLUS record, starting directly after the 4-byte CommentIdentifier and typically beginning at an offset of 40 bytes from the end of the EMF header in practice due to the fixed structure of initial fields. The first such record is the EmfPlusHeader, which defines key metadata for the EMF+ section, including the (an EmfPlusGraphicsVersion value such as 0xDBC01002, corresponding to GraphicsVersion1_1 for GDI+ 1.1), EmfPlusFlags (for example, 0x00000001 indicating no or video display reference), and the total size of the EMF+ data in bytes. The EMF+ portion optionally employs compression for its data payload, often via embedded structures like the EMR_COMMENT_EMFPLUSHEADER mechanism, which allows compact representation while supporting native 32-bit floating-point coordinates for precise positioning and transformations in drawing operations. Subsequent EMF+ records are enumerated in a sequential description table within the private data buffer, where each entry specifies the record type, offsets from the buffer start, data sizes, and processing flags to enable selective rendering—such as skipping unsupported records based on size fields or processing only essential EMF fallback commands. Overall, EMF+ integrates with by encapsulating GDI+ commands and objects within these comment records, enabling enhanced graphics features like alpha blending and gradients while providing a complete EMF subset for fallback rendering on systems lacking GDI+ support.

Records and Operations

Bitmap and Drawing Records

In Windows Metafile (WMF) format, bitmap records such as BITMAP16 (record function number 0x000B) enable the loading and definition of device-independent bitmaps (DIBs) using 16-bit parameters, including fields for bitmap type, width, height, planes, bits per pixel, and raw pixel data, which can also create pattern brushes for subsequent drawing operations. In contrast, the Enhanced Metafile (EMF) format uses records like EMR_STRETCHDIBITS (type 0x00000051) to transfer and scale DIB pixels to a destination rectangle, supporting optional stretching, compression, and integration with brush patterns for more precise raster output. These bitmap records in both formats incorporate raster operations to combine source data with the destination surface, such as SRCCOPY (0x00CC0020), which directly copies the source bitmap, and PATCOPY (0x00F00021), which applies the current brush pattern, often with clipping to the current device context bounds. Drawing records in WMF and handle vector primitives by rendering lines, polylines, and using the current for outlines, with fills implicitly applied via the selected where applicable, such as in closed shapes. In WMF, the LINETO (0x0079) draws a straight line from the current position to specified 16-bit coordinates using the current , updating the position accordingly. The POLYLINE (0x0325) extends this to multiple connected segments defined by a count of points and their 16-bit X-Y coordinates, again relying on the for rendering without filling. For curves, the (0x0817) draws an elliptical within a bounding specified by 16-bit coordinates, using start and end radial points to define the sweep angle in device units, with the for the and for any or fill if selected. EMF improves precision in these operations with 32-bit integer coordinates and floating-point support for . The EMR_LINETO record (type 0x00000036) performs a similar line draw to its WMF counterpart but uses a single 32-bit point for the . EMR_POLYLINE (type 0x00000024) renders connected lines from an of 32-bit points, maintaining compatibility with WMF while enhancing scalability for higher resolutions. Likewise, EMR_ARC (type 0x0000002D) defines arcs via a 32-bit bounding and start/end in logical units, applying the current pen for the and supporting fills for enclosed regions like sectors. Across both formats, these records assume prior selection of pen and states, ensuring that line styles, widths, colors, and fill patterns are applied consistently during playback without explicit recreation in the itself.

Object, State, and Escape Records

In Windows Metafile (WMF) and its enhanced variants, object records manage the creation and selection of graphics resources such as , pens, and fonts, which are stored in an object table for reuse during playback. The CREATEBRUSHINDIRECT record in WMF, identified by number 0x02FC, creates a logical defined by a specifying the (e.g., solid, hatched), color reference, and optional hatch pattern. This record includes a fixed-size header with the record size and identifier, followed by the LogBrush data, enabling device-independent definitions. In the Metafile () format, the equivalent is the EMR_CREATEBRUSHINDIRECT record (type 0x00000027), which uses a LogBrushEx to support additional attributes like texture bitmaps and for more precise rendering. Selection of these objects into the active device context is handled by the SELECTOBJECT , common to both formats with function/type 0x012E in WMF and type 0x00000025 in . This specifies an object index from the metafile's object table or a stock object identifier (e.g., NULL_BRUSH), activating it for subsequent drawing operations without recreating resources. The ihObject field in provides a 32-bit index, supporting up to 64K objects, while WMF uses a 16-bit for efficiency in older systems. State records preserve and restore the device context configuration, allowing complex drawing sequences to revert changes without reapplying all prior settings. In WMF, the SAVE_DC record (0x001E) pushes the current state onto a stack limited to 16 levels, capturing attributes like transformation matrices and clipping regions. The corresponding RESTORE_DC record (0x0127) pops states from this stack using a signed 16-bit offset (nSavedDC), where negative values indicate relative restoration and positive ones absolute levels. EMF mirrors this with EMR_SAVEDC (type 0x00000021), which has no parameters and appends the state to an unbounded array, and EMR_RESTOREDC (type 0x00000022), which uses a 32-bit integer for the saved state index to enable deeper nesting. Mapping modes, which define how logical coordinates map to device coordinates, are set via dedicated state records to support anisotropic and . The WMF SETMAPMODE record (0x0103) accepts a 16-bit mode value, such as MM_ANISOTROPIC for arbitrary X/Y or MM_ISOTROPIC for equal units, influencing subsequent coordinate interpretations. EMF's EMR_SETMAPMODE (type 0x00000011) uses the same enumeration but integrates with floating-point world transformations for higher precision in modern graphics pipelines. Escape records provide a mechanism for vendor-specific or device-dependent extensions, bypassing standard GDI operations. In WMF, the ESCAPE record (0x0626) includes a 16-bit escape function code (e.g., NEWFRAME for page ejection) followed by a byte count and variable data payload, allowing printer-specific commands like aborting jobs. EMF extends this with EMR_EXTESCAPE (type 0x0000006A), supporting enhanced functions such as EXTTEXTOUT for advanced text output, where the EscapeFunction field identifies the operation and cbEscData specifies the data length. Resource management is completed by deletion records to prevent memory leaks during playback. The WMF DELETEOBJECT record (0x01F0) removes a specified object from the table using its 16-bit handle, freeing associated resources like memory. In EMF, EMR_DELETEOBJECT (type 0x00000028) uses a 32-bit index for the same purpose, ensuring compatibility with larger object tables and supporting selective cleanup in nested contexts.
Record CategoryWMF Record (Function)EMF Record (Type)Key Purpose
Object CreationCREATEBRUSHINDIRECT (0x02FC)EMR_CREATEBRUSHINDIRECT (0x00000027)Define brushes with style, color, and patterns
Object SelectionSELECTOBJECT (0x012E)EMR_SELECTOBJECT (0x00000025)Activate object in device context
State Save/RestoreSAVE_DC (0x001E) / RESTORE_DC (0x0127)EMR_SAVEDC (0x00000021) / EMR_RESTOREDC (0x00000022)Stack-based context preservation
Mapping ModeSETMAPMODE (0x0103)EMR_SETMAPMODE (0x00000011)Set coordinate transformation mode
Escape (0x0626)EMR_EXTESCAPE (0x0000006A)Device-specific extensions
Object DeletionDELETEOBJECT (0x01F0)EMR_DELETEOBJECT (0x00000028)Free graphics resources

Implementations and Support

Native Windows Integration

Windows Metafiles are created within the Windows operating system using Graphics Device Interface (GDI) functions provided by the Win32 API. For Windows-format metafiles (WMF), applications invoke the CreateMetaFile function to obtain a device context suitable for recording GDI drawing operations, followed by calls to standard GDI functions such as LineTo or Ellipse to capture the graphics sequence, and finally CloseMetaFile to finalize the metafile handle. Enhanced metafiles (EMF) are recorded similarly using CreateEnhMetaFile, which supports a broader range of GDI operations including advanced features like alpha blending, and the resulting handle is retrieved via CloseEnhMetaFile. To retrieve or convert metafile data, functions like GetMetaFileBitsEx allow extraction of WMF contents into a buffer, facilitating conversion to EMF format for improved fidelity. Playback of metafiles occurs through dedicated GDI functions integrated into the Windows graphics subsystem. The PlayMetaFile function renders a WMF by enumerating and executing its records on a specified device context, ensuring device-independent reproduction of the captured graphics. For EMF files, introduced with (with enhancements in ), the PlayEnhMetaFile function maps the metafile contents onto a target rectangle in the device context, supporting playback since and later versions. These functions are implemented in the GDI32.dll library, enabling seamless integration in native Windows applications. Metafiles serve as standard formats in Windows clipboard operations and (OLE) mechanisms for exchanging . WMF and are registered clipboard formats (CF_METAFILEPICT for WMF and CF_ENHMETAFILE for ), allowing applications like and the Office suite to copy and paste graphics as device-independent pictures without loss of scalability. In OLE scenarios, embedded or linked objects from applications such as Word or Excel utilize metafiles to store and render graphical content, ensuring consistent display across documents and supporting inter-application data transfer. In the Windows printing pipeline, plays a central role in for Win32 applications via the Print API. When , GDI operations are recorded into an EMF spool file by the spooler, which the print processor then converts to a printer-specific format, optimizing for device independence and reducing in networked environments. Starting with , the XPS print path incorporates EMF+ records—extensions to EMF supporting advanced features like gradients—for in XML Paper Specification () documents, enabling higher-fidelity output in modern print drivers while maintaining compatibility with legacy GDI-based . The evolution of the GDI API reflects the transition from 16-bit Windows environments to the 32-bit Win32 architecture, with metafile support migrating to GDI32.dll for enhanced stability and functionality. In 16-bit Windows (e.g., Windows 3.1), metafile operations were handled directly in the GDI subsystem, but Win32 introduced 32-bit handles and improved error handling in functions like those in wingdi.h. Key enhancements include the SetMetaRgn function, which intersects the current clipping region with a metaregion during metafile recording or playback, allowing precise control over visible areas in vector graphics. Backward compatibility ensures that WMF playback remains supported in and 11 through the core GDI functions, allowing legacy applications and files to render correctly without modification. While direct WMF creation is deprecated in favor of , the system maintains playback via PlayMetaFile, and conversion tools can bridge formats if needed for . This ongoing support in GDI32.dll preserves the utility of older metafiles in contemporary Windows environments.

Third-Party and Cross-Platform Support

Third-party libraries have extended Windows Metafile (WMF) support to non-Windows environments, enabling rendering and conversion on and Unix systems. The libwmf library, developed as part of the wvWare project, provides functionality for interpreting WMF files and converting them to standard formats such as , , (PS), (EPS), and . This library is commonly integrated into tools like , where it facilitates WMF rendering by default using the dimensions specified in the metafile header, with options like -density for resolution adjustments during rasterization. UniConvertor, an open-source universal translator from the sK1 Project, supports importing WMF files for and within applications like . It uses the sK1 engine to handle WMF alongside other formats such as , , and CGM, allowing export to vector formats like for cross-platform vector workflows. While primarily focused on WMF, UniConvertor integrates with extensions to enable batch processing of legacy metafiles in open-source vector graphics pipelines. Commercial applications maintain compatibility with WMF and Enhanced Metafile () formats to handle legacy files from Windows ecosystems. Adobe supports importing and exporting both WMF and EMF via its Open and Place commands, preserving vector data for editing in cross-platform design projects. Similarly, CorelDRAW provides import and export capabilities for WMF, storing both and information in 24-bit RGB color, and extends support to EMF for enhanced metafile interchange in professional graphics workflows. These features ensure without native Windows dependencies, though users may encounter limitations with complex EMF+ records. ImageMagick's convert tool offers rasterization of WMF files on Unix-like systems, leveraging libwmf for accurate rendering to formats like PNG or JPEG. This command-line utility processes metafiles by translating GDI commands into pixel-based output, making it suitable for server-side image processing in web applications. Cross-platform runtime environments have implemented partial support for metafile playback to enable Windows application portability. Wine, a compatibility layer for running Windows software on Linux, includes a GDI implementation that handles WMF and EMF through its gdi32 module, allowing apps to render metafiles via translated API calls. Mono, the open-source .NET implementation, provides partial EMF+ support via its libgdiplus library, which emulates GDI+ APIs using Cairo for rendering on non-Windows platforms, though some advanced records may not be fully compatible. Conversion utilities bridge metafile formats across ecosystems. Online services like provide web-based conversion of WMF to or PDF without software installation, processing files through cloud-based rasterization and vector extraction for quick cross-format access. Open-source libraries support metafile parsing in web and enterprise contexts. Batik, a toolkit for manipulation, includes a WMFTranscoder for converting WMF files to , enabling embedding in Java-based web applications while handling basic metafile records.

Limitations and Security

Known Vulnerabilities

Windows Metafile (WMF) parsing and rendering have been associated with critical vulnerabilities primarily in the mid-2000s, enabling remote code execution through malformed records. A prominent exploit targeted the SETABORTPROC function within META_ESCAPE records, allowing attackers to execute arbitrary code by leveraging the (GDI) library in and Server 2003. This issue was addressed in Microsoft Security Bulletin MS06-001, released in January 2006, which modified WMF handling to remove support for the vulnerable record type. Enhanced Metafile (EMF) formats exhibited buffer overflow vulnerabilities in specific records, such as EMR_STRETCHDIBITS for bitmap stretching and font-related records processed via GDI+. These defects allowed heap-based overflows during rendering, potentially resulting in remote code execution when processing malicious files. Microsoft Security Bulletin MS05-053 addressed a buffer overflow in EMF rendering routines. Additional patches like MS07-017 addressed elevation-of-privilege issues in EMF rendering. EMF+ extensions in GDI+ introduced risks from compressed records, where improper decompression led to heap corruption and . Vulnerabilities in GDI+ handling of + were addressed in bulletins such as MS09-062. Microsoft provided registry-based disabling options for broader WMF/EMF support in bulletin MS09-062, referencing article 941835 for implementation, with options available since around 2008. Office 2007 incorporated enhanced safeguards against EMF rendering exploits through improved file validation in the Graphics Rendering Engine. These vulnerabilities predominantly impacted users via attachments containing malicious images or pages embedding exploitable metafiles, facilitating widespread attacks in 2005–2006. Vulnerabilities have continued post-2010, including remote code execution flaws in rendering patched in MS11-029 (2011) and MS15-035 (2015). As recently as November 2025, Research disclosed three critical vulnerabilities in the Windows (GDI), such as CVE-2025-53766, enabling remote code execution that could affect metafile processing. Mitigations like sandboxing, deprecated rendering in modern applications, and comprehensive patching have reduced but not eliminated the attack surface.

Modern Alternatives and Deprecation

The Windows Metafile (WMF) format was largely phased out in favor of the starting with , as EMF provided improved device independence and 32-bit support for better scalability in graphics rendering. further extended EMF to incorporate GDI+ features but remains limited to legacy applications relying on the GDI+ library, with shifting primary 2D graphics development to beginning in for hardware-accelerated performance. Key reasons for the decline of WMF and EMF include the base EMF's lack of native support for alpha channel opacity, restricting it to binary transparency and causing rendering issues in layered compositions. Additionally, these formats exhibit poor compatibility with mobile platforms due to their Windows-centric design and dependence on GDI, which lacks optimization for touch interfaces and cross-device portability. The rise of hardware-accelerated APIs like , underpinning , has further diminished their relevance by enabling faster, GPU-accelerated vector and raster operations without the overhead of metafile playback. Modern alternatives emphasize scalability and interoperability: (SVG) serves as a primary substitute for web-based , offering XML-based structure for resolution-independent rendering across browsers and devices. For print workflows, Portable Document Format (PDF) provides robust portability with embedded vectors and fonts, while and handle raster needs in user interfaces with better compression and transparency support. WMF and EMF persist for backward compatibility in Microsoft Office 365, particularly for legacy printing and document insertion. Microsoft recommends modern APIs like or web standards for new development. Migration tools include GDI+ APIs for converting WMF to +, such as the Metafile::ConvertToEmfPlus method, and broader .NET paths from GDI+-based WinForms to Windows Presentation Foundation (WPF), which leverages for modern vector handling.

References

  1. [1]
    [MS-WMF]: Windows Metafile Format - Microsoft Learn
    Jun 24, 2021 · A Windows metafile is a container for an image, which is defined by series of variable-length records, called metafile records.
  2. [2]
    Windows-Format Metafiles - Win32 apps | Microsoft Learn
    Apr 26, 2022 · A Windows-format metafile is used by 16-bit Windows-based applications. The format consists of a header and an array of metafile records.
  3. [3]
    [MS-WMF]: Metafile Structure - Microsoft Learn
    Apr 23, 2024 · A WMF metafile contains drawing commands, property definitions, and graphics objects in a series of WMF records. In effect, a WMF metafile is a ...
  4. [4]
    Metafiles (Windows GDI) - Win32 apps - Microsoft Learn
    Jan 7, 2021 · A metafile is a collection of structures that store a picture in a device-independent format. Device independence is the one feature that sets metafiles apart ...
  5. [5]
    [MS-WMF]: Introduction - Microsoft Learn
    Feb 14, 2019 · This is a specification of the Windows metafile format (WMF) structure, which can store an image in portable form. The.
  6. [6]
    [MS-EMF]: Introduction - Microsoft Learn
    Apr 23, 2024 · Enhanced metafile format (EMF) is a file format that is used to store portable representations of graphical images. EMF metafiles contain ...
  7. [7]
    [MS-EMF]: Enhanced Metafile Format - Microsoft Learn
    Apr 27, 2022 · Specifies the Enhanced Metafile Format (EMF) structure, which can store a picture in device-independent form.
  8. [8]
    Metafiles (GDI+) - Win32 apps | Microsoft Learn
    Jan 7, 2021 · Windows GDI+ provides the Metafile class so that you can record and display metafiles. A metafile, also called a vector image, is an image that ...Missing: independent | Show results with:independent
  9. [9]
    [MS-EMFPLUS]: Metafile Structure - Microsoft Learn
    Apr 23, 2024 · EMF+ defines a set of graphical images and text using commands, objects, and properties similar to Windows GDI+ [MSDN-GDI+].
  10. [10]
    [PDF] Windows Metafile Format (wmf) Specification
    This document is a specification of the Windows Metafile Format (WMF). A ... [MS-EMF] Microsoft Corporation, "Enhanced Metafile Format Specification", July 2007.
  11. [11]
    FAQ - Companion Software
    Jul 17, 2023 · WMF files are based on 16-bit integers with graphics coordinate limits of 0 to 16383. Doing the math, 16383 units / 2540 units/inch gives us a ...
  12. [12]
    Creating an Enhanced Metafile - Win32 apps - Microsoft Learn
    Jan 7, 2021 · This section contains an example that demonstrates the creation of an enhanced metafile that is stored on a disk, using a file name specified by the user.
  13. [13]
    [MS-EMFPLUS]: EmfPlusDrawBeziers Record - Microsoft Learn
    Oct 13, 2021 · The ending coordinate of one Bezier curve is the starting coordinate of the next. The control points are used for producing the Bezier effect.Missing: introduction 2001 GDI+ XP transparency
  14. [14]
    [MS-EMFPLUS]: Introduction - Microsoft Learn
    Apr 23, 2024 · The Enhanced Metafile Format Plus Extensions (EMF+) file structure specifies a metafile format that can store a picture in a device-independent form.
  15. [15]
    [MS-WMF]: META_HEADER Record | Microsoft Learn
    Type (2 bytes): A 16-bit unsigned integer that defines the type of metafile. · HeaderSize (2 bytes): · Version (2 bytes): · SizeLow (2 bytes): · SizeHigh (2 bytes): ...
  16. [16]
    [MS-WMF]: META_PLACEABLE Record - Microsoft Learn
    Apr 23, 2024 · The META_PLACEABLE Record is the first record in a placeable WMF metafile, which is an extension to the WMF metafile format.Missing: Windows | Show results with:Windows
  17. [17]
    MS-EMF - 2.3.4.2 EMR_HEADER Record Types - Microsoft Learn
    Apr 27, 2022 · The EMR_HEADER record is the starting point of an EMF metafile. It specifies properties of the device on which the image in the metafile was recorded.Missing: Enhanced | Show results with:Enhanced
  18. [18]
    [MS-EMF]: Header Object - Microsoft Learn
    Feb 14, 2019 · The Header object defines the EMF metafile header. It specifies properties of the device on which the image in the metafile was created.
  19. [19]
    [MS-EMF]: Metafile Structure - Microsoft Learn
    Apr 23, 2024 · An EMF metafile has an EMR_HEADER record at the start, EMR_EOF at the end, and includes an EMF header, records, and end-of-file.
  20. [20]
    [MS-EMF]: EMR_COMMENT_EMFPLUS Record | Microsoft Learn
    Feb 14, 2019 · The EMR_COMMENT_EMFPLUS record contains embedded EMF+ records ([MS-EMFPLUS] section 2.3). Fields not specified in this section are specified in ...Missing: EMR_COMMENT_EMFPLUSHEADER | Show results with:EMR_COMMENT_EMFPLUSHEADER
  21. [21]
    [MS-EMFPLUS]: EmfPlusHeader Record | Microsoft Learn
    Apr 23, 2024 · An unsigned integer that specifies the 32-bit-aligned size of the entire record in bytes, including the 12-byte record header and record-specific data.<|control11|><|separator|>
  22. [22]
    [MS-EMFPLUS]: EmfPlusHeader Example | Microsoft Learn
    This section provides an example of the EmfPlusHeader record (section 2.3.3.3).
  23. [23]
    [MS-EMFPLUS]: EmfPlusCompressedImage Object | Microsoft Learn
    Apr 23, 2024 · This object is generic and is used for different types of compressed data, including: Exchangeable Image File Format (EXIF) [EXIF];.
  24. [24]
    EMR_STRETCHDIBITS Record - MS-EMF - Microsoft Learn
    Apr 23, 2024 · The EMR_STRETCHDIBITS record specifies a block transfer of pixels from a source bitmap to a destination rectangle, optionally in combination with a brush ...Missing: overflow MS06-
  25. [25]
    [MS-EMF]: Glossary - Microsoft Learn
    Apr 27, 2022 · Windows metafile format (WMF): A file format used by Windows that supports the definition of images, including a format for clip art in word- ...
  26. [26]
  27. [27]
  28. [28]
  29. [29]
    [MS-EMF]: Object Creation Record Types - Microsoft Learn
    Oct 29, 2020 · The Object Creation record types create graphics objects. The following are EMF object creation record types.
  30. [30]
    [MS-EMF]: EMR_SELECTOBJECT Record | Microsoft Learn
    Apr 23, 2024 · The EMR_SELECTOBJECT record selects a graphics object into the playback device context. ... Type (4 bytes): An unsigned integer that identifies ...
  31. [31]
    [MS-EMF]: State Record Types - Microsoft Learn
    The State record types specify graphics properties that define the playback device context during the processing of EMF metafile records.Missing: EMR_EXTCREATEBRUSHINDIRECT | Show results with:EMR_EXTCREATEBRUSHINDIRECT
  32. [32]
    [MS-EMF]: EMF Records - Microsoft Learn
    Apr 27, 2022 · All EMF records MUST be multiples of 4 bytes in length; hence, each record starts on a 32-bit offset from the start of the metafile.
  33. [33]
    CreateMetaFileA function (wingdi.h) - Win32 apps | Microsoft Learn
    Nov 19, 2024 · The CreateMetaFileA function creates a device context for a Windows-format metafile, which can record GDI output functions.
  34. [34]
    CreateEnhMetaFileW function (wingdi.h) - Win32 apps
    May 29, 2024 · The CreateEnhMetaFile function creates a device context for an enhanced-format metafile. This device context can be used to store a device-independent picture.
  35. [35]
    GetMetaFileBitsEx function (wingdi.h) - Win32 apps | Microsoft Learn
    Feb 22, 2024 · The GetMetaFileBitsEx function retrieves the contents of a Windows-format metafile and copies them into the specified buffer.
  36. [36]
    PlayMetaFile function (wingdi.h) - Win32 apps | Microsoft Learn
    Feb 22, 2024 · The PlayMetaFile function displays a picture from a Windows-format metafile on a device. It takes a device context handle and a metafile handle ...
  37. [37]
    PlayEnhMetaFile function (wingdi.h) - Win32 apps | Microsoft Learn
    Oct 12, 2021 · The PlayEnhMetaFile function displays a picture from an enhanced-format metafile, mapping it onto a specified rectangle.
  38. [38]
    File format reference for Word, Excel, and PowerPoint - Office
    Apr 25, 2025 · Microsoft Office Clipboard file formats. Users can ... Pictures in Windows Metafile Format (WMF) or Windows Enhanced Metafile Format (EMF).
  39. [39]
    [MS-OLEDS]: Clipboard Formats - Microsoft Learn
    Apr 23, 2024 · Standard Clipboard Formats and Registered Clipboard Formats (see sections 1.3.5.1 and 1.7.1 for more details) are used to identify ...
  40. [40]
    Introduction to Printing - Windows drivers | Microsoft Learn
    Sep 27, 2024 · Spooler components interpret EMF files, and they can insert page layout information and job control instructions into the data stream. The ...
  41. [41]
    Introducing APIs for Creating XML Paper Specification Documents
    Print drivers used in versions of Windows prior to Windows Vista required the documents be spooled in Enhanced Metafile format (EMF). Since the EMF format ...
  42. [42]
    SetMetaRgn function (wingdi.h) - Win32 apps | Microsoft Learn
    Feb 22, 2024 · The SetMetaRgn function intersects the current clipping region for the specified device context with the current metaregion and saves the ...
  43. [43]
    libwmf, library to convert wmf files - wvWare - SourceForge
    libwmf is a library for reading vector images in Microsøft's native Windøws Metafile Format (WMF) and for either (a) displaying them in, eg, an X window; or (b ...
  44. [44]
    Image Formats - ImageMagick
    WMF, R, Windows Metafile, Requires libwmf. By default, renders WMF files using the dimensions specified by the metafile header. Use the -density option to ...Missing: official | Show results with:official
  45. [45]
    UniConvertor download | SourceForge.net
    Rating 4.0 (4) · Free · LinuxUniConvertor is an universal graphics translator. The project uses sK1 engine to convert one format to another. It has an import filters for: SVG, CDR, CDT, ...
  46. [46]
    UniConvertor 2.0 - Universal graphics translator - sK1 Project
    OFFICIAL SITE: UniConvertor 2.0 is a cross-platform translation hub for vector graphics, images and color palettes.Missing: EMF support
  47. [47]
    Uniconvertor - Inkscape Wiki
    Jul 12, 2007 · Uniconvertor is an universal vector graphics translator. The project uses sK1 engine to convert one format to another. Export filters:Missing: EMF support
  48. [48]
    Supported file formats for Illustrator - Adobe Help Center
    Jun 11, 2023 · This document provides an overview of file formats supported in Illustrator. For information about specific formats and their use, see Illustrator Help.Missing: legacy | Show results with:legacy
  49. [49]
    Windows Metafile Format (WMF) - CorelDRAW Help
    The Windows Metafile Format is 16 bits, while CorelDRAW is 32 bits. When you export a WMF file, the 32-bit numbers are converted to 16 bits. For example ...
  50. [50]
    Supported file formats - CorelDRAW Help
    Supported file formats · Adobe Illustrator (AI) · Adobe Type 1 Font (PFB) · Windows Bitmap (BMP) · OS/2 Bitmap (BMP) · Computer Graphics Metafile (CGM) · CorelDRAW ( ...
  51. [51]
    Command-line Tools: Convert - ImageMagick
    Use the magick program to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much ...
  52. [52]
    libgdiplus - Mono Project
    Libgdiplus is the Mono library that provides a GDI+-compatible API on non-Windows operating systems. Our implementation uses Cairo to do most of the heavy ...Missing: EMF+ | Show results with:EMF+
  53. [53]
    Apache Batik SVG Toolkit
    Batik is a Java-based toolkit for applications or applets that want to use images in the Scalable Vector Graphics (SVG) format for various purposes.Download · Using Batik · Demo · SVG DOM API
  54. [54]
    Overview (Apache Batik Javadoc)
    Provides an API for subclassing the java.awt.Graphics2D class in order to translate Java 2D primitives into another graphic format. org.apache.batik.ext.awt.
  55. [55]
    Microsoft Security Bulletin MS06-001 - Critical
    You must install this update and the update that is provided as part of the MS05-053 security bulletin to help protect your system against both vulnerabilities.Vulnerability in Graphics... · Executive Summary
  56. [56]
    Microsoft Windows buffer overflow in Enhanced Metafile rendering API
    Nov 8, 2005 · The Microsoft Windows EMF rendering routines may fail to properly check a buffer length, possibly resulting in a crash of the affected ...Missing: EMR_STRETCHDIBITS MS06-
  57. [57]
    Microsoft Security Bulletin MS07-017 - Critical
    MS05-053, Replaced, Replaced, Replaced ... A denial of service vulnerability exists in Windows when rendering Windows Metafile (WMF) image format files.Microsoft Security Bulletin... · Vulnerability Details · Security Update Information
  58. [58]
    CVE-2005-4560 - NVD
    Dec 28, 2005 · The Windows Graphical Device Interface library (GDI32.DLL) in Microsoft Windows allows remote attackers to execute arbitrary code via a Windows Metafile (WMF) ...Missing: compressed | Show results with:compressed
  59. [59]
    Microsoft Security Bulletin MS09-062 - Critical
    The instructions for disabling the EMF and WMF formats can be found in Microsoft Knowledge Base Article 941835. What is GDI+?. GDI+ is a graphics device ...
  60. [60]
    Microsoft Windows Metafile Handling Buffer Overflow - CISA
    Dec 31, 2005 · Microsoft Windows is vulnerable to remote code execution via an error in handling files using the Windows Metafile image format.Missing: EMF EMR_STRETCHDIBITS MS06- 001
  61. [61]
    Direct2D - Win32 apps - Microsoft Learn
    Jan 24, 2023 · A Direct2D resource that wraps a WMF, EMF, or EMF+ metafile. ID2D1GdiMetafile1. This interface performs all the same functions as the ...Enumerations · Functions · InterfacesMissing: shift | Show results with:shift
  62. [62]
    About Direct2D - Win32 apps - Microsoft Learn
    May 26, 2022 · Direct2D is a hardware-accelerated, immediate-mode 2-D graphics API that provides high performance and high-quality rendering for 2-D geometry, bitmaps, and ...
  63. [63]
    transparency - Does EMF (Enhanced Metafile) support opacity?
    Apr 2, 2014 · The answer is no: EMF (or WMF) image format supports full transparency but not opacity between 0.0 and 1.0 because it doesn't support colors with alpha channel.Missing: bezier curves records
  64. [64]
    Windows Metafile FAQ - Companion Software
    Aug 1, 2024 · 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) ...
  65. [65]
    Comparing Direct2D and GDI Hardware Acceleration - Win32 apps
    Jan 3, 2022 · This topic explores the differences between Direct2D and GDI, including past and present differences in the hardware acceleration features of both APIs.Missing: replacement EMF
  66. [66]
  67. [67]
    Graphic file types you can insert and save - Microsoft Support
    You can insert any of the graphic file types listed below in Office documents. The graphic files that you insert are saved with the Office documents.
  68. [68]
    Metafile::ConvertToEmfPlus (gdiplusheaders.h) - Win32 apps
    The Metafile::ConvertToEmfPlus method converts a Metafile object to EMF+ format, replacing its records. It can also create dual format with EMF and EMF+ ...
  69. [69]
    Imaging Overview - WPF - Microsoft Learn
    WPF Imaging is designed to overcome the shortcomings of GDI and GDI+ and provide a new set of API to display and use images within your applications. There are ...Missing: Metafile | Show results with:Metafile