Skip to content

Commit c04013f

Browse files
authored
Merge branch 'master' into winbuild-rewrite
2 parents 2df26d8 + a9cd55b commit c04013f

64 files changed

Lines changed: 2340 additions & 2332 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test-docker.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ jobs:
1414
arch,
1515
ubuntu-16.04-xenial-amd64,
1616
ubuntu-18.04-bionic-amd64,
17+
ubuntu-20.04-focal-amd64,
1718
debian-9-stretch-x86,
1819
debian-10-buster-x86,
1920
centos-6-amd64,
2021
centos-7-amd64,
2122
centos-8-amd64,
2223
amazon-1-amd64,
2324
amazon-2-amd64,
24-
fedora-30-amd64,
2525
fedora-31-amd64,
26+
fedora-32-amd64,
2627
]
2728
dockerTag: [master]
2829

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ matrix:
2828

2929
- python: "pypy3"
3030
name: "PyPy3 Xenial"
31+
- python: "3.9-dev"
32+
name: "3.9-dev Xenial"
33+
services: xvfb
3134
- python: "3.8"
3235
name: "3.8 Xenial"
3336
services: xvfb

CHANGES.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22
Changelog (Pillow)
33
==================
44

5+
7.2.0 (unreleased)
6+
------------------
7+
8+
- Fixed bug when unpickling TIFF images #4565
9+
[radarhere]
10+
11+
- Fix pickling WebP #4561
12+
[hugovk, radarhere]
13+
14+
7.1.2 (2020-04-25)
15+
------------------
16+
17+
- Raise an EOFError when seeking too far in PNG #4528
18+
[radarhere]
19+
520
7.1.1 (2020-04-02)
621
------------------
722

MANIFEST.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ exclude .appveyor.yml
2121
exclude .coveragerc
2222
exclude .editorconfig
2323
exclude .readthedocs.yml
24-
exclude azure-pipelines.yml
2524
exclude codecov.yml
2625
global-exclude .git*
2726
global-exclude *.pyc
2827
global-exclude *.so
29-
prune .azure-pipelines
3028
prune .ci

Tests/helper.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,8 @@ def on_github_actions():
272272

273273

274274
def on_ci():
275-
# Travis and AppVeyor have "CI"
276-
# Azure Pipelines has "TF_BUILD"
277-
# GitHub Actions has "GITHUB_ACTIONS"
278-
return (
279-
"CI" in os.environ or "TF_BUILD" in os.environ or "GITHUB_ACTIONS" in os.environ
280-
)
275+
# GitHub Actions, Travis and AppVeyor have "CI"
276+
return "CI" in os.environ
281277

282278

283279
def is_big_endian():

Tests/test_file_wmf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_load_set_dpi():
6666
assert im.size == (164, 164)
6767

6868
with Image.open("Tests/images/drawing_wmf_ref_144.png") as expected:
69-
assert_image_similar(im, expected, 2.0)
69+
assert_image_similar(im, expected, 2.1)
7070

7171

7272
def test_save(tmp_path):

Tests/test_imagefile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ def test_safeblock(self):
9595

9696
def test_raise_ioerror(self):
9797
with pytest.raises(IOError):
98-
with pytest.raises(DeprecationWarning):
98+
with pytest.warns(DeprecationWarning) as record:
9999
ImageFile.raise_ioerror(1)
100+
assert len(record) == 1
100101

101102
def test_raise_oserror(self):
102103
with pytest.raises(OSError):

Tests/test_pickle.py

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import pickle
22

3+
import pytest
34
from PIL import Image
45

6+
from .helper import skip_unless_feature
57

6-
def helper_pickle_file(tmp_path, pickle, protocol=0, mode=None):
8+
9+
def helper_pickle_file(tmp_path, pickle, protocol, test_file, mode):
710
# Arrange
8-
with Image.open("Tests/images/hopper.jpg") as im:
11+
with Image.open(test_file) as im:
912
filename = str(tmp_path / "temp.pkl")
1013
if mode:
1114
im = im.convert(mode)
@@ -20,9 +23,7 @@ def helper_pickle_file(tmp_path, pickle, protocol=0, mode=None):
2023
assert im == loaded_im
2124

2225

23-
def helper_pickle_string(
24-
pickle, protocol=0, test_file="Tests/images/hopper.jpg", mode=None
25-
):
26+
def helper_pickle_string(pickle, protocol, test_file, mode):
2627
with Image.open(test_file) as im:
2728
if mode:
2829
im = im.convert(mode)
@@ -35,41 +36,31 @@ def helper_pickle_string(
3536
assert im == loaded_im
3637

3738

38-
def test_pickle_image(tmp_path):
39+
@pytest.mark.parametrize(
40+
("test_file", "test_mode"),
41+
[
42+
("Tests/images/hopper.jpg", None),
43+
("Tests/images/hopper.jpg", "L"),
44+
("Tests/images/hopper.jpg", "PA"),
45+
pytest.param(
46+
"Tests/images/hopper.webp", None, marks=skip_unless_feature("webp")
47+
),
48+
("Tests/images/hopper.tif", None),
49+
("Tests/images/test-card.png", None),
50+
("Tests/images/zero_bb.png", None),
51+
("Tests/images/zero_bb_scale2.png", None),
52+
("Tests/images/non_zero_bb.png", None),
53+
("Tests/images/non_zero_bb_scale2.png", None),
54+
("Tests/images/p_trns_single.png", None),
55+
("Tests/images/pil123p.png", None),
56+
("Tests/images/itxt_chunks.png", None),
57+
],
58+
)
59+
def test_pickle_image(tmp_path, test_file, test_mode):
3960
# Act / Assert
4061
for protocol in range(0, pickle.HIGHEST_PROTOCOL + 1):
41-
helper_pickle_string(pickle, protocol)
42-
helper_pickle_file(tmp_path, pickle, protocol)
43-
44-
45-
def test_pickle_p_mode():
46-
# Act / Assert
47-
for test_file in [
48-
"Tests/images/test-card.png",
49-
"Tests/images/zero_bb.png",
50-
"Tests/images/zero_bb_scale2.png",
51-
"Tests/images/non_zero_bb.png",
52-
"Tests/images/non_zero_bb_scale2.png",
53-
"Tests/images/p_trns_single.png",
54-
"Tests/images/pil123p.png",
55-
"Tests/images/itxt_chunks.png",
56-
]:
57-
for protocol in range(0, pickle.HIGHEST_PROTOCOL + 1):
58-
helper_pickle_string(pickle, protocol=protocol, test_file=test_file)
59-
60-
61-
def test_pickle_pa_mode(tmp_path):
62-
# Act / Assert
63-
for protocol in range(0, pickle.HIGHEST_PROTOCOL + 1):
64-
helper_pickle_string(pickle, protocol, mode="PA")
65-
helper_pickle_file(tmp_path, pickle, protocol, mode="PA")
66-
67-
68-
def test_pickle_l_mode(tmp_path):
69-
# Act / Assert
70-
for protocol in range(0, pickle.HIGHEST_PROTOCOL + 1):
71-
helper_pickle_string(pickle, protocol, mode="L")
72-
helper_pickle_file(tmp_path, pickle, protocol, mode="L")
62+
helper_pickle_string(pickle, protocol, test_file, test_mode)
63+
helper_pickle_file(tmp_path, pickle, protocol, test_file, test_mode)
7364

7465

7566
def test_pickle_la_mode_with_palette(tmp_path):
@@ -88,3 +79,15 @@ def test_pickle_la_mode_with_palette(tmp_path):
8879

8980
im.mode = "PA"
9081
assert im == loaded_im
82+
83+
84+
@skip_unless_feature("webp")
85+
def test_pickle_tell():
86+
# Arrange
87+
image = Image.open("Tests/images/hopper.webp")
88+
89+
# Act: roundtrip
90+
unpickled_image = pickle.loads(pickle.dumps(image))
91+
92+
# Assert
93+
assert unpickled_image.tell() == 0

docs/installation.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,18 @@ These platforms are built and tested for every change.
394394
+----------------------------------+--------------------------+-----------------------+
395395
| Debian 10 Buster | 3.7 |x86 |
396396
+----------------------------------+--------------------------+-----------------------+
397-
| Fedora 30 | 3.7 |x86-64 |
398-
+----------------------------------+--------------------------+-----------------------+
399397
| Fedora 31 | 3.7 |x86-64 |
400398
+----------------------------------+--------------------------+-----------------------+
399+
| Fedora 32 | 3.8 |x86-64 |
400+
+----------------------------------+--------------------------+-----------------------+
401401
| macOS 10.15 Catalina | 3.5, 3.6, 3.7, 3.8, PyPy3|x86-64 |
402402
+----------------------------------+--------------------------+-----------------------+
403403
| Ubuntu Linux 16.04 LTS | 3.5, 3.6, 3.7, 3.8, PyPy3|x86-64 |
404404
+----------------------------------+--------------------------+-----------------------+
405+
| Ubuntu Linux 18.04 LTS | 3.6 |x86-64 |
406+
+----------------------------------+--------------------------+-----------------------+
407+
| Ubuntu Linux 20.04 LTS | 3.8 |x86-64 |
408+
+----------------------------------+--------------------------+-----------------------+
405409
| Windows Server 2016 | 3.8 |x86 |
406410
| +--------------------------+-----------------------+
407411
| | 3.5 |x86-64 |

docs/reference/ImageDraw.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,25 @@ Example: Draw Partial Opacity Text
100100
101101
out.show()
102102
103+
Example: Draw Multiline Text
104+
----------------------------
105+
106+
.. code-block:: python
107+
108+
from PIL import Image, ImageDraw, ImageFont
109+
110+
# create an image
111+
out = Image.new("RGB", (150, 100), (255, 255, 255))
112+
113+
# get a font
114+
fnt = ImageFont.truetype("Pillow/Tests/fonts/FreeMono.ttf", 40)
115+
# get a drawing context
116+
d = ImageDraw.Draw(out)
117+
118+
# draw multiline text
119+
d.multiline_text((10,10), "Hello\nWorld", font=fnt, fill=(0, 0, 0))
120+
121+
out.show()
103122
104123
105124
Functions

0 commit comments

Comments
 (0)