Skip to content

Commit

Permalink
Merge branch 'main' into comment_correct_placement
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere authored May 22, 2022
2 parents 6257e78 + 30a0e44 commit db76eaa
Show file tree
Hide file tree
Showing 38 changed files with 290 additions and 204 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/test-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
matrix:
docker: [
# Run slower jobs first to give them a headstart and reduce waiting time
ubuntu-20.04-focal-arm64v8,
ubuntu-20.04-focal-ppc64le,
ubuntu-20.04-focal-s390x,
ubuntu-22.04-jammy-arm64v8,
ubuntu-22.04-jammy-ppc64le,
ubuntu-22.04-jammy-s390x,
# Then run the remainder
alpine,
amazon-2-amd64,
Expand All @@ -32,11 +32,11 @@ jobs:
]
dockerTag: [main]
include:
- docker: "ubuntu-20.04-focal-arm64v8"
- docker: "ubuntu-22.04-jammy-arm64v8"
qemu-arch: "aarch64"
- docker: "ubuntu-20.04-focal-ppc64le"
- docker: "ubuntu-22.04-jammy-ppc64le"
qemu-arch: "ppc64le"
- docker: "ubuntu-20.04-focal-s390x"
- docker: "ubuntu-22.04-jammy-s390x"
qemu-arch: "s390x"

name: ${{ matrix.docker }}
Expand Down
30 changes: 27 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ Changelog (Pillow)
9.2.0 (unreleased)
------------------

- Separate multiple GIF comment blocks with newlines #6294
[raygard, radarhere]

- Always use GIF89a for comments #6292
[raygard, radarhere]

- Ignore compression value from BMP info dictionary when saving as TIFF #6231
[radarhere]

- If font is file-like object, do not re-read from object to get variant #6234
[radarhere]

- Raise ValueError when trying to access internal fp after close #6213
[radarhere]

- Support more affine expression forms in im.point() #6254
[benrg, radarhere]

- Populate Python palette in fromarray() #6283
[radarhere]

Expand All @@ -17,9 +35,6 @@ Changelog (Pillow)
- Adjust BITSPERSAMPLE to match SAMPLESPERPIXEL when opening TIFFs #6270
[radarhere]

- Do not open images with zero or negative height #6269
[radarhere]

- Search pkgconf system libs/cflags #6138
[jameshilliard, radarhere]

Expand Down Expand Up @@ -50,6 +65,15 @@ Changelog (Pillow)
- Deprecated PhotoImage.paste() box parameter #6178
[radarhere]

9.1.1 (2022-05-17)
------------------

- When reading past the end of a TGA scan line, reduce bytes left. CVE-2022-30595
[radarhere]

- Do not open images with zero or negative height #6269
[radarhere]

9.1.0 (2022-04-01)
------------------

Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ release-test:
sdist:
python3 -m build --help > /dev/null 2>&1 || python3 -m pip install build
python3 -m build --sdist
python3 -m twine --help > /dev/null 2>&1 || python3 -m pip install twine
python3 -m twine check --strict dist/*

.PHONY: test
test:
Expand Down
3 changes: 0 additions & 3 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Released quarterly on January 2nd, April 1st, July 1st and October 15th.
* [ ] Create and check source distribution:
```bash
make sdist
python3 -m twine check --strict dist/*
```
* [ ] Create [binary distributions](https://github.com/python-pillow/Pillow/blob/main/RELEASING.md#binary-distributions)
* [ ] Check and upload all binaries and source distributions e.g.:
Expand Down Expand Up @@ -61,7 +60,6 @@ Released as needed for security, installation or critical bug fixes.
* [ ] Create and check source distribution:
```bash
make sdist
python3 -m twine check --strict dist/*
```
* [ ] Create [binary distributions](https://github.com/python-pillow/Pillow/blob/main/RELEASING.md#binary-distributions)
* [ ] Check and upload all binaries and source distributions e.g.:
Expand Down Expand Up @@ -91,7 +89,6 @@ Released as needed privately to individual vendors for critical security-related
* [ ] Create and check source distribution:
```bash
make sdist
python3 -m twine check --strict dist/*
```
* [ ] Create [binary distributions](https://github.com/python-pillow/Pillow/blob/main/RELEASING.md#binary-distributions)
* [ ] Publish the [release on GitHub](https://github.com/python-pillow/Pillow/releases)
Expand Down
Binary file added Tests/images/cross_scan_line_truncated.tga
Binary file not shown.
Binary file added Tests/images/multiple_comments.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions Tests/test_file_apng.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,15 @@ def test_apng_save_blend(tmp_path):
assert im.getpixel((0, 0)) == (0, 255, 0, 255)


def test_seek_after_close():
im = Image.open("Tests/images/apng/delay.png")
im.seek(1)
im.close()

with pytest.raises(ValueError):
im.seek(0)


def test_constants_deprecation():
for enum, prefix in {
PngImagePlugin.Disposal: "APNG_DISPOSE_",
Expand Down
9 changes: 9 additions & 0 deletions Tests/test_file_fli.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ def test_closed_file():
im.close()


def test_seek_after_close():
im = Image.open(animated_test_file)
im.seek(1)
im.close()

with pytest.raises(ValueError):
im.seek(0)


def test_context_manager():
with warnings.catch_warnings():
with Image.open(static_test_file) as im:
Expand Down
26 changes: 25 additions & 1 deletion Tests/test_file_gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ def test_closed_file():
im.close()


def test_seek_after_close():
im = Image.open("Tests/images/iss634.gif")
im.load()
im.close()

with pytest.raises(ValueError):
im.is_animated
with pytest.raises(ValueError):
im.n_frames
with pytest.raises(ValueError):
im.seek(1)


def test_context_manager():
with warnings.catch_warnings():
with Image.open(TEST_GIF) as im:
Expand Down Expand Up @@ -794,6 +807,9 @@ def test_comment(tmp_path):
with Image.open(out) as reread:
assert reread.info["comment"] == im.info["comment"].encode()

# Test that GIF89a is used for comments
assert reread.info["version"] == b"GIF89a"


def test_comment_over_255(tmp_path):
out = str(tmp_path / "temp.gif")
Expand All @@ -804,15 +820,23 @@ def test_comment_over_255(tmp_path):
im.info["comment"] = comment
im.save(out)
with Image.open(out) as reread:

assert reread.info["comment"] == comment

# Test that GIF89a is used for comments
assert reread.info["version"] == b"GIF89a"


def test_zero_comment_subblocks():
with Image.open("Tests/images/hopper_zero_comment_subblocks.gif") as im:
assert_image_equal_tofile(im, TEST_GIF)


def test_read_multiple_comment_blocks():
with Image.open("Tests/images/multiple_comments.gif") as im:
# Multiple comment blocks in a frame are separated not concatenated
assert im.info["comment"] == b"Test comment 1\nTest comment 2"


def test_write_comment(tmp_path):
out = str(tmp_path / "temp.gif")
with Image.open("Tests/images/dispose_prev.gif") as im:
Expand Down
2 changes: 2 additions & 0 deletions Tests/test_file_libtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
hopper,
mark_if_feature_version,
skip_unless_feature,
skip_unless_feature_version,
)


Expand Down Expand Up @@ -991,6 +992,7 @@ def test_sampleformat_not_corrupted(self):
with Image.open(out) as im:
im.load()

@skip_unless_feature_version("libtiff", "4.0.4")
def test_realloc_overflow(self):
TiffImagePlugin.READ_LIBTIFF = True
with Image.open("Tests/images/tiff_overflow_rows_per_strip.tif") as im:
Expand Down
8 changes: 8 additions & 0 deletions Tests/test_file_mpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ def test_closed_file():
im.close()


def test_seek_after_close():
im = Image.open(test_files[0])
im.close()

with pytest.raises(ValueError):
im.seek(1)


def test_context_manager():
with warnings.catch_warnings():
with Image.open(test_files[0]) as im:
Expand Down
4 changes: 4 additions & 0 deletions Tests/test_file_tga.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ def test_cross_scan_line():
with Image.open("Tests/images/cross_scan_line.tga") as im:
assert_image_equal_tofile(im, "Tests/images/cross_scan_line.png")

with Image.open("Tests/images/cross_scan_line_truncated.tga") as im:
with pytest.raises(OSError):
im.load()


def test_save(tmp_path):
test_file = "Tests/images/tga_id_field.tga"
Expand Down
16 changes: 16 additions & 0 deletions Tests/test_file_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ def test_closed_file(self):
im.load()
im.close()

def test_seek_after_close(self):
im = Image.open("Tests/images/multipage.tiff")
im.close()

with pytest.raises(ValueError):
im.n_frames
with pytest.raises(ValueError):
im.seek(1)

def test_context_manager(self):
with warnings.catch_warnings():
with Image.open("Tests/images/multipage.tiff") as im:
Expand Down Expand Up @@ -706,6 +715,13 @@ def test_save_icc_profile(self, tmp_path):
with Image.open(outfile) as reloaded:
assert reloaded.info["icc_profile"] == icc_profile

def test_save_bmp_compression(self, tmp_path):
with Image.open("Tests/images/hopper.bmp") as im:
assert im.info["compression"] == 0

outfile = str(tmp_path / "temp.tif")
im.save(outfile)

def test_discard_icc_profile(self, tmp_path):
outfile = str(tmp_path / "temp.tif")

Expand Down
24 changes: 22 additions & 2 deletions Tests/test_image_point.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest

from PIL import Image

from .helper import assert_image_equal, hopper


Expand All @@ -17,11 +19,24 @@ def test_sanity():
im.point(list(range(256)))
im.point(lambda x: x * 1)
im.point(lambda x: x + 1)
im.point(lambda x: x - 1)
im.point(lambda x: x * 1 + 1)
im.point(lambda x: 0.1 + 0.2 * x)
im.point(lambda x: -x)
im.point(lambda x: x - 0.5)
im.point(lambda x: 1 - x / 2)
im.point(lambda x: (2 + x) / 3)
im.point(lambda x: 0.5)
im.point(lambda x: x / 1)
im.point(lambda x: x + x)
with pytest.raises(TypeError):
im.point(lambda x: x * x)
with pytest.raises(TypeError):
im.point(lambda x: x / x)
with pytest.raises(TypeError):
im.point(lambda x: x - 1)
im.point(lambda x: 1 / x)
with pytest.raises(TypeError):
im.point(lambda x: x / 1)
im.point(lambda x: x // 2)


def test_16bit_lut():
Expand All @@ -47,3 +62,8 @@ def test_f_mode():
im = hopper("F")
with pytest.raises(ValueError):
im.point(None)


def test_coerce_e_deprecation():
with pytest.warns(DeprecationWarning):
assert Image.coerce_e(2).data == 2
5 changes: 4 additions & 1 deletion Tests/test_imagefont.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ def _font_as_bytes(self):
return font_bytes

def test_font_with_filelike(self):
ImageFont.truetype(
ttf = ImageFont.truetype(
self._font_as_bytes(), FONT_SIZE, layout_engine=self.LAYOUT_ENGINE
)
ttf_copy = ttf.font_variant()
assert ttf_copy.font_bytes == ttf.font_bytes

self._render(self._font_as_bytes())
# Usage note: making two fonts from the same buffer fails.
# shared_bytes = self._font_as_bytes()
Expand Down
2 changes: 1 addition & 1 deletion depends/install_openjpeg.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# install openjpeg

archive=openjpeg-2.4.0
archive=openjpeg-2.5.0

./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz

Expand Down
8 changes: 8 additions & 0 deletions docs/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ in Pillow 10 (2023-07-01). Upgrade to
`PyQt6 <https://www.riverbankcomputing.com/static/Docs/PyQt6/>`_ or
`PySide6 <https://doc.qt.io/qtforpython/>`_ instead.

Image.coerce_e
~~~~~~~~~~~~~~

.. deprecated:: 9.2.0

This undocumented method has been deprecated and will be removed in Pillow 10
(2023-07-01).

Removed features
----------------

Expand Down
9 changes: 4 additions & 5 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ Many of Pillow's features require external libraries:

* **openjpeg** provides JPEG 2000 functionality.

* Pillow has been tested with openjpeg **2.0.0**, **2.1.0**, **2.3.1** and **2.4.0**.
* Pillow has been tested with openjpeg **2.0.0**, **2.1.0**, **2.3.1**,
**2.4.0** and **2.5.0**.
* Pillow does **not** support the earlier **1.5** series which ships
with Debian Jessie.

Expand Down Expand Up @@ -474,11 +475,9 @@ These platforms are built and tested for every change.
+----------------------------------+----------------------------+---------------------+
| Ubuntu Linux 20.04 LTS (Focal) | 3.7, 3.8, 3.9, 3.10, 3.11, | x86-64 |
| | PyPy3 | |
| +----------------------------+---------------------+
| | 3.8 | arm64v8, ppc64le, |
| | | s390x |
+----------------------------------+----------------------------+---------------------+
| Ubuntu Linux 22.04 LTS (Jammy) | 3.10 | x86-64 |
| Ubuntu Linux 22.04 LTS (Jammy) | 3.10 | arm64v8, ppc64le, |
| | | s390x, x86-64 |
+----------------------------------+----------------------------+---------------------+
| Windows Server 2016 | 3.7 | x86-64 |
+----------------------------------+----------------------------+---------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/releasenotes/8.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Previously, if a BMP file was too large, an ``OSError`` would be raised. Now,
Dark theme for docs
^^^^^^^^^^^^^^^^^^^

The https://pillow.readthedocs.io documentation will use a dark theme if the the user has requested the system use one. Uses the ``prefers-color-scheme`` CSS media query.
The https://pillow.readthedocs.io documentation will use a dark theme if the user has requested the system use one. Uses the ``prefers-color-scheme`` CSS media query.



Loading

0 comments on commit db76eaa

Please sign in to comment.