Skip to content

Commit

Permalink
Updated WMF documentation [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Dec 29, 2019
1 parent 61d0784 commit feec1bb
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 32 deletions.
69 changes: 37 additions & 32 deletions docs/handbook/image-file-formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^

Expand Down Expand Up @@ -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")
12 changes: 12 additions & 0 deletions docs/releasenotes/7.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=============

Expand Down

0 comments on commit feec1bb

Please sign in to comment.