Skip to main content
Metafile Render — WMF and EMF to SVG, PNG, JPEG, and WebP

Metafile Render

Windows metafiles, ready for the modern web.

PyPI Downloads Downloads/month Python CI License: MIT

English · 简体中文

Quick start · Usage · Reference

Overview

Metafile Render converts Windows Metafile (WMF) and Enhanced Metafile (EMF) graphics into SVG, PNG, JPEG, and WebP. Use it to display legacy graphics in a browser or process metafile images extracted from Office documents.

  • Cross-platform — runs on Linux, macOS, and Windows.
  • Simple setup — only Pillow and pyclipper; no Office or external converter required.
  • Python and CLI — integrate a single function or convert files from your terminal.
  • Visible diagnostics — inspect partial rendering, approximations, and skipped content.

Quick start

Requires GIL-enabled CPython 3.11–3.14.

pip install metafile-render

Convert an existing EMF file to SVG:

metafile-render input.emf -o output.svg

WMF files use the same command. The output extension selects the format.

Usage

Python

from pathlib import Path
from metafile_render import render_metafile

result = render_metafile(
    Path("input.emf").read_bytes(),
    output_format="svg",
)
Path("output.svg").write_bytes(result.data)

print(result.width, result.height, result.media_type)
if result.partial:
    print("Partial rendering.")
for item in result.diagnostics:
    print(item.code, item.message)

render_metafile() takes bytes and returns image bytes, dimensions, format information, and diagnostics. Its default output is PNG at 200 DPI.

Python option Default Purpose
output_format "png" svg, png, jpeg, or webp
dpi None → 200 Resolution for all outputs, including SVG; integer from 1 to 1200
size_hint None Pixel dimensions (width, height); useful for WMF without physical dimensions
backend "auto" Automatic backend selection; "replay" forces the portable engine

Canvas limits may reduce the requested dimensions. See the API reference for result fields and error handling.

Command line

metafile-render input.emf -o output.png --dpi 300
metafile-render input.emf -o output.webp
metafile-render input.emf -o transparent.png --backend replay
metafile-render input.wmf -o sized.png --size 800 600
python -m metafile_render input.emf -o output.jpg --force

Supported extensions: .svg, .png, .jpg, .jpeg, and .webp. The output directory must exist. Use --force to replace an existing output; input and output must be different files. Diagnostics are printed to stderr.

Rendering notes

Topic What to expect
Backends SVG always uses portable replay. With auto, eligible raster outputs use Pillow's native GDI renderer on Windows and replay elsewhere; native capability/load failures fall back to replay.
Transparency Replay preserves transparency in PNG and WebP. Native GDI and JPEG use a white background.
SVG Output is self-contained, including embedded images. Some operations use a raster image inside SVG.
EMF+ Common EMF+ Only content is supported. Dual files use their EMF fallback stream. Full GDI+ fidelity is not guaranteed.
Fonts System fonts are used and may be substituted. Install the source document's fonts for closer text fidelity.

The Rust extension is required. Releases provide cp311-abi3 wheels for Linux x86-64/aarch64, Windows x64/ARM64, and macOS 14+ arm64. Pure Python wheels and source distributions are not published.

Approximated or skipped content is reported through partial=True and diagnostics. Font substitution or a backend fallback alone does not mark a result as partial. Malformed, unsupported, or over-budget inputs can raise MetafileError; the CLI reports conversion errors with a nonzero exit code. A completed partial conversion exits with code 0.

Documentation and support

  • Agent skill — conversion workflows and diagnostic handling for agents. Copy the skills/metafile-render directory into your agent's supported skills directory to use it.
  • Technical reference — full API and CLI contracts, formats, fonts, and resource limits.
  • Development guide — local checks, architecture, benchmarks, and publishing.
  • Report an issue — include a sample file, conversion options, and diagnostics when possible.

License

MIT · Copyright © 2026 Xiaomeng Zhao (myhloli).

Metadata

Release files for metafile-render 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for metafile-render 0.4.0
File Actions
metafile_render-0.4.0-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details for metafile_render-0.4.0-cp311-abi3-win_arm64.whl
metafile_render-0.4.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for metafile_render-0.4.0-cp311-abi3-win_amd64.whl
metafile_render-0.4.0-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details for metafile_render-0.4.0-cp311-abi3-manylinux_2_28_x86_64.whl
metafile_render-0.4.0-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details for metafile_render-0.4.0-cp311-abi3-manylinux_2_28_aarch64.whl
metafile_render-0.4.0-cp311-abi3-macosx_14_0_arm64.whl CPython 3.11 abi3 macOS 14.0+ ARM64 Details for metafile_render-0.4.0-cp311-abi3-macosx_14_0_arm64.whl

Total release size: 1.4 MB

Release files / metafile_render-0.4.0-cp311-abi3-win_arm64.whl

Download URL metafile_render-0.4.0-cp311-abi3-win_arm64.whl
Size 207.2 kB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
701695eef1b1f8c7b7116d6a6807724674b763e8c471a43d9fb382500a6b7bbb
BLAKE2b-256 checksum
How to use checksums
b4966203bfef77e22796a1c857bb77c68de0db8af783325594bf0afdd7b99f11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / metafile_render-0.4.0-cp311-abi3-win_amd64.whl

Download URL metafile_render-0.4.0-cp311-abi3-win_amd64.whl
Size 209.0 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
73f9e762818cd63ac50be1ed7b0f760fb101341f9a923cea36f5c1fb0b270d22
BLAKE2b-256 checksum
How to use checksums
21d5c02c2c2f1eac087440b35c62ab231b04b84c42b29ce9783913a009c23d86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / metafile_render-0.4.0-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL metafile_render-0.4.0-cp311-abi3-manylinux_2_28_x86_64.whl
Size 344.8 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
6a68ea3cd18fe7ac483e9ddd1343757efd0e7301f4e4d87b50e0c015ea26398a
BLAKE2b-256 checksum
How to use checksums
5fcc518dfcc6b11ceb51e02215667fe022b21ebe4827baad2128931c73c0c722
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / metafile_render-0.4.0-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL metafile_render-0.4.0-cp311-abi3-manylinux_2_28_aarch64.whl
Size 335.4 kB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
cc92007e28094eafcdfc11492376c20af043eaab1695728bbd0e81c4d9592c79
BLAKE2b-256 checksum
How to use checksums
8a1767d8c262f300b6473aa895866300822cb2f0ad96aff1b999f9e0cd6ebf65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / metafile_render-0.4.0-cp311-abi3-macosx_14_0_arm64.whl

Download URL metafile_render-0.4.0-cp311-abi3-macosx_14_0_arm64.whl
Size 309.2 kB
Tags CPython 3.11 abi3 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
13d6297a48ab01ab14f74142c2d84c7cdc3efe86dbc03eac0bd4356c4a8b11c0
BLAKE2b-256 checksum
How to use checksums
1b6603bde9b6d98b6027dc0cf74da290ec7964e6cd2aa1a75cea8fd2c29b96b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for metafile-render 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for metafile_render-0.4.0-cp311-abi3-win_arm64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page