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

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

Total release size: 1.4 MB

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

Download URL metafile_render-0.4.1-cp311-abi3-win_arm64.whl
Size 210.4 kB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
f909ff39ab61f1b452a89a6e6317bec516566634478517470f3465c91aefbe5b
BLAKE2b-256 checksum
How to use checksums
55d32c3c5a0a1aa873bc78137e3ebfd6765285e79076c211bba28ee7ff19decc
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.1-cp311-abi3-win_amd64.whl

Download URL metafile_render-0.4.1-cp311-abi3-win_amd64.whl
Size 211.5 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0ec423f3a7c08fdda5e59f607889ae527d862d79b9439afe87d2c934d0297a7a
BLAKE2b-256 checksum
How to use checksums
e6be61b931a9034ba793bf5db5e783f2ec0ae2cc8f4e921734caf9a8b7179775
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.1-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL metafile_render-0.4.1-cp311-abi3-manylinux_2_28_x86_64.whl
Size 347.2 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
b0aaa0315824908273f77aa8cc7210070f43f22d5463a288e788121175cb523e
BLAKE2b-256 checksum
How to use checksums
d8a02525b40220307aff34935e3c2c6d10ff8a664c1d5e12baeb741f3e2a5c9b
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.1-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL metafile_render-0.4.1-cp311-abi3-manylinux_2_28_aarch64.whl
Size 338.6 kB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
a700f049527e3123c6e385f7dc8086e54013437c277491c70f046725dbfd6476
BLAKE2b-256 checksum
How to use checksums
9e5b8c602e8fe75596eb05407e1b323aabc3f0841c8aa757861d85cf14525cac
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.1-cp311-abi3-macosx_14_0_arm64.whl

Download URL metafile_render-0.4.1-cp311-abi3-macosx_14_0_arm64.whl
Size 311.2 kB
Tags CPython 3.11 abi3 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
4ab36dda32d1464118c1798bd48e84ab95c42b93a8fb088ccae47b5f4049ae6e
BLAKE2b-256 checksum
How to use checksums
2560fc3509596d1072b54bbeaeb1ea236063edd1bc165c266c38fc9c86e7fe00
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.1

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