Updated WMF documentation [ci skip]

This commit is contained in:
Andrew Murray 2019-12-30 10:12:37 +11:00
parent 61d0784933
commit feec1bbcb2
2 changed files with 49 additions and 32 deletions

View File

@ -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")

View File

@ -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
=============