Skip to content

Commit 605208e

Browse files
authored
Merge branch 'main' into perspective
2 parents ccdea48 + b1f549f commit 605208e

11 files changed

Lines changed: 149 additions & 19 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ As of 2019, Pillow development is
6565
<a href="https://tidelift.com/subscription/pkg/pypi-pillow?utm_source=pypi-pillow&utm_medium=badge"><img
6666
alt="Tidelift"
6767
src="https://tidelift.com/badges/package/pypi/Pillow?style=flat"></a>
68-
<a href="https://pypi.org/project/Pillow/"><img
68+
<a href="https://pypi.org/project/pillow/"><img
6969
alt="Newest PyPI version"
7070
src="https://img.shields.io/pypi/v/pillow.svg"></a>
71-
<a href="https://pypi.org/project/Pillow/"><img
71+
<a href="https://pypi.org/project/pillow/"><img
7272
alt="Number of PyPI downloads"
7373
src="https://img.shields.io/pypi/dm/pillow.svg"></a>
7474
<a href="https://www.bestpractices.dev/projects/6331"><img

Tests/images/hopper.pfm

64 KB
Binary file not shown.

Tests/images/hopper_be.pfm

64 KB
Binary file not shown.

Tests/test_file_ppm.py

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66

77
from PIL import Image, PpmImagePlugin
88

9-
from .helper import assert_image_equal_tofile, assert_image_similar, hopper
9+
from .helper import (
10+
assert_image_equal,
11+
assert_image_equal_tofile,
12+
assert_image_similar,
13+
hopper,
14+
)
1015

1116
# sample ppm stream
1217
TEST_FILE = "Tests/images/hopper.ppm"
@@ -84,20 +89,58 @@ def test_16bit_pgm():
8489

8590
def test_16bit_pgm_write(tmp_path):
8691
with Image.open("Tests/images/16_bit_binary.pgm") as im:
87-
f = str(tmp_path / "temp.pgm")
88-
im.save(f, "PPM")
92+
filename = str(tmp_path / "temp.pgm")
93+
im.save(filename, "PPM")
8994

90-
assert_image_equal_tofile(im, f)
95+
assert_image_equal_tofile(im, filename)
9196

9297

9398
def test_pnm(tmp_path):
9499
with Image.open("Tests/images/hopper.pnm") as im:
95100
assert_image_similar(im, hopper(), 0.0001)
96101

97-
f = str(tmp_path / "temp.pnm")
98-
im.save(f)
102+
filename = str(tmp_path / "temp.pnm")
103+
im.save(filename)
104+
105+
assert_image_equal_tofile(im, filename)
106+
107+
108+
def test_pfm(tmp_path):
109+
with Image.open("Tests/images/hopper.pfm") as im:
110+
assert im.info["scale"] == 1.0
111+
assert_image_equal(im, hopper("F"))
112+
113+
filename = str(tmp_path / "tmp.pfm")
114+
im.save(filename)
115+
116+
assert_image_equal_tofile(im, filename)
117+
118+
119+
def test_pfm_big_endian(tmp_path):
120+
with Image.open("Tests/images/hopper_be.pfm") as im:
121+
assert im.info["scale"] == 2.5
122+
assert_image_equal(im, hopper("F"))
99123

100-
assert_image_equal_tofile(im, f)
124+
filename = str(tmp_path / "tmp.pfm")
125+
im.save(filename)
126+
127+
assert_image_equal_tofile(im, filename)
128+
129+
130+
@pytest.mark.parametrize(
131+
"data",
132+
[
133+
b"Pf 1 1 NaN \0\0\0\0",
134+
b"Pf 1 1 inf \0\0\0\0",
135+
b"Pf 1 1 -inf \0\0\0\0",
136+
b"Pf 1 1 0.0 \0\0\0\0",
137+
b"Pf 1 1 -0.0 \0\0\0\0",
138+
],
139+
)
140+
def test_pfm_invalid(data):
141+
with pytest.raises(ValueError):
142+
with Image.open(BytesIO(data)):
143+
pass
101144

102145

103146
@pytest.mark.parametrize(

docs/about.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The fork author's goal is to foster and support active development of PIL throug
1313
.. _GitHub Actions: https://github.com/python-pillow/Pillow/actions
1414
.. _AppVeyor: https://ci.appveyor.com/project/Python-pillow/pillow
1515
.. _GitHub: https://github.com/python-pillow/Pillow
16-
.. _Python Package Index: https://pypi.org/project/Pillow/
16+
.. _Python Package Index: https://pypi.org/project/pillow/
1717

1818
License
1919
-------

docs/handbook/image-file-formats.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,25 @@ PCX
696696

697697
Pillow reads and writes PCX files containing ``1``, ``L``, ``P``, or ``RGB`` data.
698698

699+
PFM
700+
^^^
701+
702+
.. versionadded:: 10.3.0
703+
704+
Pillow reads and writes grayscale (Pf format) Portable FloatMap (PFM) files
705+
containing ``F`` data.
706+
707+
Color (PF format) PFM files are not supported.
708+
709+
Opening
710+
~~~~~~~
711+
712+
The :py:func:`~PIL.Image.open` function sets the following
713+
:py:attr:`~PIL.Image.Image.info` properties:
714+
715+
**scale**
716+
The absolute value of the number stored in the *Scale Factor / Endianness* line.
717+
699718
PNG
700719
^^^
701720

docs/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ Pillow for enterprise is available via the Tidelift Subscription. `Learn more <h
5858
:alt: Fuzzing Status
5959

6060
.. image:: https://img.shields.io/pypi/v/pillow.svg
61-
:target: https://pypi.org/project/Pillow/
61+
:target: https://pypi.org/project/pillow/
6262
:alt: Latest PyPI version
6363

6464
.. image:: https://img.shields.io/pypi/dm/pillow.svg
65-
:target: https://pypi.org/project/Pillow/
65+
:target: https://pypi.org/project/pillow/
6666
:alt: Number of PyPI downloads
6767

6868
.. image:: https://www.bestpractices.dev/projects/6331/badge

docs/installation.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ After navigating to the Pillow directory, run::
385385
python3 -m pip install --upgrade pip
386386
python3 -m pip install .
387387

388-
.. _compressed archive from PyPI: https://pypi.org/project/Pillow/#files
388+
.. _compressed archive from PyPI: https://pypi.org/project/pillow/#files
389389

390390
Build Options
391391
"""""""""""""
@@ -602,5 +602,5 @@ Old Versions
602602
------------
603603

604604
You can download old distributions from the `release history at PyPI
605-
<https://pypi.org/project/Pillow/#history>`_ and by direct URL access
606-
eg. https://pypi.org/project/Pillow/1.0/.
605+
<https://pypi.org/project/pillow/#history>`_ and by direct URL access
606+
eg. https://pypi.org/project/pillow/1.0/.

docs/releasenotes/10.3.0.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
10.3.0
2+
------
3+
4+
Backwards Incompatible Changes
5+
==============================
6+
7+
TODO
8+
^^^^
9+
10+
Deprecations
11+
============
12+
13+
TODO
14+
^^^^
15+
16+
TODO
17+
18+
API Changes
19+
===========
20+
21+
TODO
22+
^^^^
23+
24+
TODO
25+
26+
API Additions
27+
=============
28+
29+
TODO
30+
^^^^
31+
32+
TODO
33+
34+
Security
35+
========
36+
37+
TODO
38+
^^^^
39+
40+
TODO
41+
42+
Other Changes
43+
=============
44+
45+
Portable FloatMap (PFM) images
46+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47+
48+
Support has been added for reading and writing grayscale (Pf format)
49+
Portable FloatMap (PFM) files containing ``F`` data.

docs/releasenotes/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ expected to be backported to earlier versions.
1414
.. toctree::
1515
:maxdepth: 2
1616

17+
10.3.0
1718
10.2.0
1819
10.1.0
1920
10.0.1

0 commit comments

Comments
 (0)