From a1635ac6c45ab4731700336d128ec720cec77857 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 28 Dec 2019 09:01:29 +1100 Subject: [PATCH 1/6] Updated CHANGES.rst [ci skip] --- CHANGES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 8693df466..7fb0802d6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,9 @@ Changelog (Pillow) 7.0.0 (unreleased) ------------------ +- Added reduce operation #4251 + [homm] + - Raise ValueError for io.StringIO in Image.open #4302 [radarhere, hugovk] From 61d07849335715b978235ad452e89b56f30ad757 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 28 Dec 2019 11:25:39 +1100 Subject: [PATCH 2/6] Allow loading of WMF images at a given DPI --- Tests/images/drawing_wmf_ref_144.png | Bin 0 -> 1209 bytes Tests/test_file_wmf.py | 11 +++++++++++ src/PIL/WmfImagePlugin.py | 22 +++++++++++++++++----- 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 Tests/images/drawing_wmf_ref_144.png diff --git a/Tests/images/drawing_wmf_ref_144.png b/Tests/images/drawing_wmf_ref_144.png new file mode 100644 index 0000000000000000000000000000000000000000..20ed9ce597b5f648871c3210a4a560987f38ed61 GIT binary patch literal 1209 zcmeAS@N?(olHy`uVBq!ia0vp^OF)=|2}n-6E+odlz|!F9;uumf=k1-llO8DuI6Umz z`u_i^o7~Hie0V-xc5t3wygM}e$!s>+$2q_EasPaA{{?qI-fgqH{|lBT-Vm!WdUe46 z?7pzgN$w4z^ZlQ+XB;b?&AFTZ!{f#F|1axgTQGi`{PDo+x+e2|GnQ?9e}--SSHAo* zPu(Q{#G3Q_cIm$HoOwP{ZF^H~qFJGDY3voZqe4TNArjmT;UbD}Z%1_oS_G`_* z^!w7KqUxr*bx+GP52VD;*jrlmZqJXs>bG}p;gS7VH<|bI(tpbLGB-`!cfJ0|Y=5&e z_OHzz<*G}+oU*I8!uiePUDNB+L+@91-m2Vw$j&=BY3<(G3CgiC!TGg0OSH3}ukGpG z;?=vybmPRZHLcsF%r3oJS^YXe`L0H6K5NdB*~?zUcK4RFZ`reY!^C&fy2>rhF3ny2 zUGIonmB-Y3sy96N*QA|2y}fXWyJ*mf+)he_J)TKUeK`V1hMQj{Dvg=IXC~$+J&_R5L*Z8{cYdfT#xwKGJWm&P?7E z3)T-Z^6hWEIJGNZ@PJA?bLmZ?Ot&U9_B7&YPHER zD^`}h6sdG`^4YY!<#%ps*U#_$zM`oA)ncJHj}t$^YL9f5FBVzq`tftlo~xIqirt+p{vpgK zHtNdzkb}`n#V%cXv`uA?cD9Oc?>ooCyLXgby7aEic@KA%magx6J=-L?6u zcJb!-{O5)*d-+x|dj4$xZEyef?6~=Kg>> Date: Sun, 29 Dec 2019 22:52:50 +0100 Subject: [PATCH 3/6] don't skip test fixed in pypy 7.3.0 --- Tests/test_main.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Tests/test_main.py b/Tests/test_main.py index 4f52149b6..d0f1410e7 100644 --- a/Tests/test_main.py +++ b/Tests/test_main.py @@ -1,17 +1,10 @@ import os import subprocess import sys -import unittest from unittest import TestCase -from .helper import is_pypy, is_win32, on_github_actions - class TestMain(TestCase): - @unittest.skipIf( - is_win32() and is_pypy() and on_github_actions(), - "Failing on Windows on GitHub Actions running PyPy", - ) def test_main(self): out = subprocess.check_output([sys.executable, "-m", "PIL"]).decode("utf-8") lines = out.splitlines() From 2b96dcffe15be628cbc1e49da6479948b20f2646 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 30 Dec 2019 09:18:03 +1100 Subject: [PATCH 4/6] Removed TODO from release notes [ci skip] --- docs/releasenotes/7.0.0.rst | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/docs/releasenotes/7.0.0.rst b/docs/releasenotes/7.0.0.rst index cf88dfa64..f581f31a4 100644 --- a/docs/releasenotes/7.0.0.rst +++ b/docs/releasenotes/7.0.0.rst @@ -73,18 +73,6 @@ bounds of resulting image. This may be useful in a subsequent .. _chain methods: https://en.wikipedia.org/wiki/Method_chaining -API Changes -=========== - -Deprecations -^^^^^^^^^^^^ - -TODO -~~~~ - -TODO - - API Additions ============= From feec1bbcb22045dbdcd90074f568d7f114079ae2 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 30 Dec 2019 10:12:37 +1100 Subject: [PATCH 5/6] 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 ============= From 40106e7d368809475607147f51c63d0c0003bcff Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 30 Dec 2019 10:27:14 +1100 Subject: [PATCH 6/6] Updated CHANGES.rst [ci skip] --- CHANGES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 7fb0802d6..3a2a45441 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,9 @@ Changelog (Pillow) 7.0.0 (unreleased) ------------------ +- Allow loading of WMF images at a given DPI #4311 + [radarhere] + - Added reduce operation #4251 [homm]