Metadata-Version: 2.4
Name: pillow_wmf
Version: 0.2.0
Summary: A Windows MetaFile loader for Pillow
Author-email: Gareth Davidson <gaz@bitplane.net>
Requires-Python: >=3.13
Description-Content-Type: text/markdown
License-Expression: LicenseRef-WTFPL-With-Warranty AND LGPL-2.1-or-later AND OFL-1.1
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
License-File: LICENSE.md
License-File: src/pillow_wmf/fonts/OFL.txt
License-File: src/pillow_wmf/fonts/README.md
License-File: src/pillow_wmf/fonts/symbol/COPYING.LIB
License-File: src/pillow_wmf/fonts/symbol/README.md
Requires-Dist: pillow>=12.3
Requires-Dist: fonttools>=4.65
Requires-Dist: freetype-py>=2.5
Requires-Dist: pre-commit ; extra == "dev"
Requires-Dist: pytest ; extra == "dev"
Requires-Dist: coverage ; extra == "dev"
Requires-Dist: pytest-cov ; extra == "dev"
Requires-Dist: build ; extra == "dev"
Requires-Dist: twine ; extra == "dev"
Requires-Dist: ruff==0.16.7 ; extra == "dev"
Requires-Dist: pydoc-markdown ; extra == "dev"
Project-URL: Issues, https://github.com/bitplane/pillow-wmf/issues
Project-URL: Repository, https://github.com/bitplane/pillow-wmf
Provides-Extra: dev

# pillow-wmf

A Windows Metafile reader/writer/renderer for Pillow.

Like in the old Windows days, a GDI backend draws graphics and can also record
actions to a Windows Metafile. Rasterizing one of these WMFs is just a matter
of playing it back, which produces a Pillow Image.

## Links

* [🏠 home](https://bitplane.net/dev/python/pillow-wmf)
* [😺 source](https://github.com/bitplane/pillow-wmf)
* [🐍 pypi](https://pypi.org/project/pillow-wmf)

## Usage

```python
from PIL import Image
import pillow_wmf  # registers the WMF loader ahead of Pillow's built-in stub

with Image.open("drawing.wmf") as image:
    image.load(size=(640, 480))
    image.save("drawing.png")
```

## Rendering limits

`render(data, size, limits=Limits(...))` bounds input bytes, records, points,
objects and saved DC states. `max_bitmap_pixels` limits each decoded bitmap
or glyph. `max_geometry_points` (default 1,000,000) limits cumulative curve
flattening and dynamic pen expansion, including their stroke caps, joins and
repeated realizations. Input polygon points, fixed-size stroke bodies and
fixed-table pens (including their caps and joins) do not spend this expansion
budget.
Pen realization and identical stroke coverage are reused within one drawing
operation. Reusing them does not spend the allowance again; subsequent
operations generate and charge their own geometry.
The geometry allowance belongs to the raster context and is not restored by
`RestoreDC`. Each flattened curve also has a fixed 65,536-point limit.
`RasterContext` accepts `max_objects`, `max_saved_states`, `max_bitmap_pixels`
and `max_geometry_points` for direct drawing. `render()` passes its `Limits`
object's object/save allowances to the backend; Pillow loading uses the defaults.
Default policy values are defined in `pillow_wmf.limits`.

Resource exhaustion raises `pillow_wmf.binary.ResourceLimitError`, including
during `play(..., strict=False)`; it is never treated as a recoverable omission.
An execution-time failure makes the context unusable and may leave partial
pixels. Pillow reports rendering resource failures as `OSError`. These limits
bound particular allocations and generated geometry, not total rendering time.

## Drawing diagnostics

`RasterContext` and `Recorder` retain requested calls by default for existing
diagnostic callers. Pass `trace_calls=False` to omit that history; WMF recording,
handle validation and saved drawing state still work. `RecordingContext` also
accepts this option for its own history, independently of its two backends.
`render()` and the Pillow loader disable call history because they only return
pixels. `TraceContext` remains the backend for collecting a command trace.

## License

pillow-wmf is WTFPL with one additional clause:

1. Don't blame me.

Fonts have their own licenses, rip them out if you don't want to comply:

* [Wingdings fallback (OFL-1.1)](src/pillow_wmf/fonts/OFL.txt)
* [Wine Symbol (LGPL-2.1-or-later)](src/pillow_wmf/fonts/symbol/COPYING.LIB)


