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.

Text cleanup reports text_control_filtered when paragraph separators or XML-invalid characters are removed from a single-line text run. A known RAQM layout failure skips only the affected text command and reports text_layout_failed. Both set partial=True; explicit character advances, background rectangles, and unrelated drawing commands are preserved.

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.2

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.2
File Actions
metafile_render-0.4.2-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details for metafile_render-0.4.2-cp311-abi3-win_arm64.whl
metafile_render-0.4.2-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for metafile_render-0.4.2-cp311-abi3-win_amd64.whl
metafile_render-0.4.2-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details for metafile_render-0.4.2-cp311-abi3-manylinux_2_28_x86_64.whl
metafile_render-0.4.2-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details for metafile_render-0.4.2-cp311-abi3-manylinux_2_28_aarch64.whl
metafile_render-0.4.2-cp311-abi3-macosx_14_0_arm64.whl CPython 3.11 abi3 macOS 14.0+ ARM64 Details for metafile_render-0.4.2-cp311-abi3-macosx_14_0_arm64.whl

Total release size: 1.4 MB

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

Download URL metafile_render-0.4.2-cp311-abi3-win_arm64.whl
Size 213.4 kB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
f2b5bf91e4a995b357da308f09fa838efe4aaf856fa95af18aaab4d089cc4593
BLAKE2b-256 checksum
How to use checksums
c61b30ed24689a528c5189be6e59392a12de9cf96126884710d534338b009574
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 Nov 2, 2026.

Transparency log

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

Download URL metafile_render-0.4.2-cp311-abi3-win_amd64.whl
Size 214.5 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9c49f054650310e6aa01369663c5a8c5d5967914a11c572e789200b2e4fb1298
BLAKE2b-256 checksum
How to use checksums
958ba5856037d565e7f6563c96450d5b39e5014895c9e39ca6e75c7666287aaa
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 Nov 2, 2026.

Transparency log

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

Download URL metafile_render-0.4.2-cp311-abi3-manylinux_2_28_x86_64.whl
Size 350.1 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
269faeba770cfd16b0ac43012a67c13a587e7976e0b22661d93a2dd828745e00
BLAKE2b-256 checksum
How to use checksums
b50f1fcbd5b7aade208ee7908f9c8a5e8ad7d501fc724ab236697457d02f28ec
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 Nov 2, 2026.

Transparency log

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

Download URL metafile_render-0.4.2-cp311-abi3-manylinux_2_28_aarch64.whl
Size 341.6 kB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
a52b5100c253f59d5effdf9cdcd9d95c95b7db84775e767ad1ad3aee293b6115
BLAKE2b-256 checksum
How to use checksums
91cd78e5734df4e733c7c6efa58d0266ba129d9e3c02d9d1e939a9248dadb1e2
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 Nov 2, 2026.

Transparency log

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

Download URL metafile_render-0.4.2-cp311-abi3-macosx_14_0_arm64.whl
Size 314.2 kB
Tags CPython 3.11 abi3 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
3ef55d600a0970d8f8cbb0c2cc2d8295e3118dbfe783226b2085d876077389ea
BLAKE2b-256 checksum
How to use checksums
88e75f4b78e9f2e335a98ac9aa0c73f4ff3fd97a437dd1a28c553ee04b43b7c3
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 Nov 2, 2026.

Transparency log

Security for metafile-render 0.4.2

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.2-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 Nov 2, 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