From feec1bbcb22045dbdcd90074f568d7f114079ae2 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 30 Dec 2019 10:12:37 +1100 Subject: [PATCH] Updated WMF documentation [ci skip] --- docs/handbook/image-file-formats.rst | 69 +++++++++++++++------------- docs/releasenotes/7.0.0.rst | 12 +++++ 2 files changed, 49 insertions(+), 32 deletions(-) diff --git a/docs/handbook/image-file-formats.rst b/docs/handbook/image-file-formats.rst index 088fd5a03..0e068c1e4 100644 --- a/docs/handbook/image-file-formats.rst +++ b/docs/handbook/image-file-formats.rst @@ -1019,6 +1019,43 @@ this format. By default, a Quake2 standard palette is attached to the texture. To override the palette, use the putpalette method. +WMF +^^^ + +Pillow can identify WMF files. + +On Windows, it can read WMF files. By default, it will load the image at 72 +dpi. To load it at another resolution: + +.. code-block:: python + + from PIL import Image + with Image.open("drawing.wmf") as im: + im.load(dpi=144) + +To add other read or write support, use +:py:func:`PIL.WmfImagePlugin.register_handler` to register a WMF handler. + +.. code-block:: python + + from PIL import Image + from PIL import WmfImagePlugin + + class WmfHandler: + def open(self, im): + ... + def load(self, im): + ... + return image + def save(self, im, fp, filename): + ... + + wmf_handler = WmfHandler() + + WmfImagePlugin.register_handler(wmf_handler) + + im = Image.open("sample.wmf") + XPM ^^^ @@ -1176,35 +1213,3 @@ MPEG ^^^^ Pillow identifies MPEG files. - -WMF -^^^ - -Pillow can identify playable WMF files. - -In PIL 1.1.4 and earlier, the WMF driver provides some limited rendering -support, but not enough to be useful for any real application. - -In PIL 1.1.5 and later, the WMF driver is a stub driver. To add WMF read or -write support to your application, use -:py:func:`PIL.WmfImagePlugin.register_handler` to register a WMF handler. - -:: - - from PIL import Image - from PIL import WmfImagePlugin - - class WmfHandler: - def open(self, im): - ... - def load(self, im): - ... - return image - def save(self, im, fp, filename): - ... - - wmf_handler = WmfHandler() - - WmfImagePlugin.register_handler(wmf_handler) - - im = Image.open("sample.wmf") diff --git a/docs/releasenotes/7.0.0.rst b/docs/releasenotes/7.0.0.rst index cf88dfa64..9a4b5a42b 100644 --- a/docs/releasenotes/7.0.0.rst +++ b/docs/releasenotes/7.0.0.rst @@ -94,6 +94,18 @@ Custom unidentified image error Pillow will now throw a custom ``UnidentifiedImageError`` when an image cannot be identified. For backwards compatibility, this will inherit from ``IOError``. +Loading WMF images at a given DPI +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +On Windows, Pillow can read WMF files, with a default DPI of 72. An image can +now also be loaded at another resolution: + +.. code-block:: python + + from PIL import Image + with Image.open("drawing.wmf") as im: + im.load(dpi=144) + Other Changes =============