A Visual Studio Code extension that allows you to preview WMF (Windows Metafile Format) and EMF (Enhanced Metafile Format) images directly in the editor.
- π Preview WMF, EMF, and EMF+ files directly in VSCode
- πΌοΈ Supports both view and editor modes
- π¨ High-quality Canvas 2D rendering
- π Context menu integration for quick access
- π Automatic file type detection
- π― Comprehensive format support (WMF, EMF, EMF+)
- WMF (Windows Metafile) - Classic vector graphics format
- EMF (Enhanced Metafile) - Enhanced version with better features
- EMF+ (Enhanced Metafile Plus) - Modern format with advanced graphics
- Open VSCode
- Go to Extensions view (
Ctrl+Shift+X/Cmd+Shift+X) - Search for "WMF/EMF Viewer"
- Click "Install"
- Download the
.vsixfile from releases - Open VSCode
- Go to Extensions view (
Ctrl+Shift+X/Cmd+Shift+X) - Click on the three dots (
...) in the top right corner - Select "Install from VSIX..."
- Navigate to the downloaded
.vsixfile and select it
# Clone the repository
git clone https://github.com/vscode-extensions/wmf-viewer.git
cd wmf-viewer
# Install dependencies
npm install
# Build the extension
npm run build
# Press F5 in VSCode to run in debug mode- Right-click on a
.wmfor.emffile in the Explorer - Select "Preview WMF/EMF Image"
- The image will open in a new preview tab
- Simply click on a
.wmfor.emffile - The file will automatically open in the WMF/EMF Viewer editor
WmfEmfViewer/
βββ .vscode/ # VSCode workspace configuration
βββ docs/ # Documentation and format specifications
βββ scripts/ # Development and analysis scripts
βββ src/ # Source code
β βββ build/ # Build scripts
β βββ commands/ # VSCode command implementations
β βββ modules/ # Core parsing and rendering
β β βββ drawers/ # Format-specific renderers
β β βββ parsers/ # Format-specific parsers
β βββ providers/ # VSCode provider implementations
β βββ resources/ # Static resources (HTML templates)
β βββ utils/ # Utility modules
β βββ extension.ts # Main extension entry point
βββ test/ # Test files and examples
βββ test_files/ # Sample WMF/EMF files for testing
βββ out/ # Compiled output (gitignored)
βββ package.json # Package configuration
βββ tsconfig.json # TypeScript configuration
βββ README.md # This file
- Node.js (v16+)
- npm (v7+)
- Visual Studio Code (v1.75.0+)
# Install dependencies
npm install
# Build the extension (bundle + compile)
npm run build
# Build browser bundle only
npm run build:bundle
# Compile TypeScript to JavaScript
npm run compile
# Watch for changes and compile automatically
npm run watch
# Lint TypeScript files
npm run lint
# Run tests
npm run test
# Package the extension into a VSIX file
npm run package- Setup:
npm install - Development:
npm run watch(in terminal) + PressF5(to debug) - Testing: Open any
.wmfor.emffile in the Extension Development Host - Building:
npm run build - Packaging:
npm run package
The extension follows a modular architecture:
- Providers: Handle VSCode integration (custom editor, commands)
- Parsers: Parse binary WMF/EMF/EMF+ file formats
- Drawers: Render parsed data to Canvas 2D
- Utils: Helper functions (coordinate transformation, GDI object management)
- Build: Scripts to bundle modules for browser compatibility
The extension uses a multi-format parsing strategy:
- File Type Detection: Automatically detects WMF, EMF, or EMF+ format
- Format-Specific Parsing: Uses specialized parsers for each format
- Record Processing: Parses metafile records sequentially
- Coordinate Transformation: Applies appropriate transformations for Canvas rendering
- Parse binary metafile data
- Extract drawing commands and GDI objects
- Transform coordinates to Canvas coordinate system
- Render using Canvas 2D API in webview
- AGENTS.md: Comprehensive guide for AI coding agents
- docs/PROJECT_STRUCTURE.md: Detailed project structure documentation
- docs/[MS-WMF].pdf: WMF format specification
- docs/[MS-EMF].pdf: EMF format specification
- docs/[MS-EMFPLUS].pdf: EMF+ format specification
Sample WMF/EMF files are available in test_files/ directory for testing various format features.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch
- Make your changes
- Run
npm run lintand fix any issues - Test your changes with sample files
- Submit a Pull Request
- Based on Microsoft's WMF, EMF, and EMF+ format specifications
- Built with TypeScript and VSCode extension API
- Uses Canvas 2D API for high-quality rendering
For issues, questions, or feature requests, please visit the GitHub repository.

