From e946c7b14adc7a0aaa9ac883de217a3c0e556a81 Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Fri, 7 Mar 2025 02:42:10 +1100 Subject: [PATCH 01/10] Test using _seek to skip frames (#8804) Co-authored-by: Andrew Murray --- Tests/test_file_apng.py | 5 ++++- Tests/test_file_fli.py | 3 +++ Tests/test_file_gif.py | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Tests/test_file_apng.py b/Tests/test_file_apng.py index 9d5154fca..b9a036173 100644 --- a/Tests/test_file_apng.py +++ b/Tests/test_file_apng.py @@ -34,8 +34,11 @@ def test_apng_basic() -> None: with pytest.raises(EOFError): im.seek(2) - # test rewind support im.seek(0) + with pytest.raises(ValueError, match="cannot seek to frame 2"): + im._seek(2) + + # test rewind support assert im.getpixel((0, 0)) == (255, 0, 0, 255) assert im.getpixel((64, 32)) == (255, 0, 0, 255) im.seek(1) diff --git a/Tests/test_file_fli.py b/Tests/test_file_fli.py index 8adbd30f5..8a95af62d 100644 --- a/Tests/test_file_fli.py +++ b/Tests/test_file_fli.py @@ -160,6 +160,9 @@ def test_seek() -> None: assert_image_equal_tofile(im, "Tests/images/a_fli.png") + with pytest.raises(ValueError, match="cannot seek to frame 52"): + im._seek(52) + @pytest.mark.parametrize( "test_file", diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index d2592da97..dbbffc675 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -410,6 +410,10 @@ def test_seek() -> None: except EOFError: assert frame_count == 5 + img.seek(0) + with pytest.raises(ValueError, match="cannot seek to frame 2"): + img._seek(2) + def test_seek_info() -> None: with Image.open("Tests/images/iss634.gif") as im: From 5575c1d072a127e10cf0077ca9dcb7d54ea06c06 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 8 Mar 2025 09:56:00 +1100 Subject: [PATCH 02/10] Test missing frame size --- Tests/test_file_fli.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Tests/test_file_fli.py b/Tests/test_file_fli.py index 8a95af62d..2f39adc69 100644 --- a/Tests/test_file_fli.py +++ b/Tests/test_file_fli.py @@ -1,5 +1,6 @@ from __future__ import annotations +import io import warnings import pytest @@ -132,6 +133,15 @@ def test_eoferror() -> None: im.seek(n_frames - 1) +def test_missing_frame_size() -> None: + with open(animated_test_file, "rb") as fp: + data = fp.read() + data = data[:6188] + with Image.open(io.BytesIO(data)) as im: + with pytest.raises(EOFError, match="missing frame size"): + im.seek(1) + + def test_seek_tell() -> None: with Image.open(animated_test_file) as im: layer_number = im.tell() From baa299a6f42d691653f3a6dcfb067be567319c27 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 8 Mar 2025 09:54:46 +1100 Subject: [PATCH 03/10] Moved code outside of context manager --- Tests/test_file_jpeg2k.py | 10 +++++----- Tests/test_file_pcx.py | 4 ++-- Tests/test_font_bdf.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Tests/test_file_jpeg2k.py b/Tests/test_file_jpeg2k.py index 01172fdbb..e429610ad 100644 --- a/Tests/test_file_jpeg2k.py +++ b/Tests/test_file_jpeg2k.py @@ -317,12 +317,12 @@ def test_grayscale_four_channels() -> None: with open("Tests/images/rgb_trns_ycbc.jp2", "rb") as fp: data = fp.read() - # Change color space to OPJ_CLRSPC_GRAY - data = data[:76] + b"\x11" + data[77:] + # Change color space to OPJ_CLRSPC_GRAY + data = data[:76] + b"\x11" + data[77:] - with Image.open(BytesIO(data)) as im: - im.load() - assert im.mode == "RGBA" + with Image.open(BytesIO(data)) as im: + im.load() + assert im.mode == "RGBA" @pytest.mark.skipif( diff --git a/Tests/test_file_pcx.py b/Tests/test_file_pcx.py index aa24189f4..21c32268c 100644 --- a/Tests/test_file_pcx.py +++ b/Tests/test_file_pcx.py @@ -40,7 +40,7 @@ def test_sanity(tmp_path: Path) -> None: def test_bad_image_size() -> None: with open("Tests/images/pil184.pcx", "rb") as fp: data = fp.read() - data = data[:4] + b"\xff\xff" + data[6:] + data = data[:4] + b"\xff\xff" + data[6:] b = io.BytesIO(data) with pytest.raises(SyntaxError, match="bad PCX image size"): @@ -51,7 +51,7 @@ def test_bad_image_size() -> None: def test_unknown_mode() -> None: with open("Tests/images/pil184.pcx", "rb") as fp: data = fp.read() - data = data[:3] + b"\xff" + data[4:] + data = data[:3] + b"\xff" + data[4:] b = io.BytesIO(data) with pytest.raises(OSError, match="unknown PCX mode"): diff --git a/Tests/test_font_bdf.py b/Tests/test_font_bdf.py index 2ece5457a..b4155c879 100644 --- a/Tests/test_font_bdf.py +++ b/Tests/test_font_bdf.py @@ -20,8 +20,8 @@ def test_sanity() -> None: def test_zero_width_chars() -> None: with open(filename, "rb") as fp: data = fp.read() - data = data[:2650] + b"\x00\x00" + data[2652:] - BdfFontFile.BdfFontFile(io.BytesIO(data)) + data = data[:2650] + b"\x00\x00" + data[2652:] + BdfFontFile.BdfFontFile(io.BytesIO(data)) def test_invalid_file() -> None: From a38d4d2583c9ce6e944d44efdb4d5a7106d42ec5 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 10 Mar 2025 22:44:13 +0100 Subject: [PATCH 04/10] Replace deprecated Renovate schedule with cron syntax --- .github/renovate.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/renovate.json b/.github/renovate.json index f48b670ec..91fa0426f 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -16,6 +16,6 @@ } ], "schedule": [ - "on the 3rd day of the month" + "* * 3 * *" ] } From 4b9d9f55cdd567d90ea8d885a50489ffd2ccfe2b Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Wed, 12 Mar 2025 09:59:25 +1100 Subject: [PATCH 05/10] Updated libtiff to 4.7.0 (#8812) Co-authored-by: Andrew Murray --- .github/workflows/wheels-dependencies.sh | 2 +- docs/installation/building-from-source.rst | 2 +- winbuild/build_prepare.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wheels-dependencies.sh b/.github/workflows/wheels-dependencies.sh index 202a8935d..e9c54536e 100755 --- a/.github/workflows/wheels-dependencies.sh +++ b/.github/workflows/wheels-dependencies.sh @@ -43,7 +43,7 @@ LIBPNG_VERSION=1.6.47 JPEGTURBO_VERSION=3.1.0 OPENJPEG_VERSION=2.5.3 XZ_VERSION=5.6.4 -TIFF_VERSION=4.6.0 +TIFF_VERSION=4.7.0 LCMS2_VERSION=2.17 ZLIB_NG_VERSION=2.2.4 LIBWEBP_VERSION=1.5.0 diff --git a/docs/installation/building-from-source.rst b/docs/installation/building-from-source.rst index b400a3436..2790bc2e6 100644 --- a/docs/installation/building-from-source.rst +++ b/docs/installation/building-from-source.rst @@ -44,7 +44,7 @@ Many of Pillow's features require external libraries: * **libtiff** provides compressed TIFF functionality - * Pillow has been tested with libtiff versions **3.x** and **4.0-4.6.0** + * Pillow has been tested with libtiff versions **3.x** and **4.0-4.7.0** * **libfreetype** provides type related services diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py index a645722d8..ea3d99394 100644 --- a/winbuild/build_prepare.py +++ b/winbuild/build_prepare.py @@ -120,7 +120,7 @@ V = { "LIBPNG": "1.6.47", "LIBWEBP": "1.5.0", "OPENJPEG": "2.5.3", - "TIFF": "4.6.0", + "TIFF": "4.7.0", "XZ": "5.6.4", "ZLIBNG": "2.2.4", } From d97441cb86f1f9187ee303210ccdd34b2f899f6b Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Fri, 14 Mar 2025 17:49:59 +1100 Subject: [PATCH 06/10] Install libtiff-dev (#8816) Co-authored-by: Andrew Murray --- .ci/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/install.sh b/.ci/install.sh index e61752750..62677005e 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -20,7 +20,7 @@ fi set -e if [[ $(uname) != CYGWIN* ]]; then - sudo apt-get -qq install libfreetype6-dev liblcms2-dev python3-tk\ + sudo apt-get -qq install libfreetype6-dev liblcms2-dev libtiff-dev python3-tk\ ghostscript libjpeg-turbo8-dev libopenjp2-7-dev\ cmake meson imagemagick libharfbuzz-dev libfribidi-dev\ sway wl-clipboard libopenblas-dev From 5efcaa460372e91d9d18f2f812f590728903927a Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Fri, 14 Mar 2025 17:50:28 +1100 Subject: [PATCH 07/10] Updated Ghostscript to 10.5.0 (#8814) Co-authored-by: Andrew Murray --- .github/workflows/test-windows.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index ef49ff332..a780c7835 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -94,8 +94,8 @@ jobs: choco install nasm --no-progress echo "C:\Program Files\NASM" >> $env:GITHUB_PATH - choco install ghostscript --version=10.4.0 --no-progress - echo "C:\Program Files\gs\gs10.04.0\bin" >> $env:GITHUB_PATH + choco install ghostscript --version=10.5.0 --no-progress + echo "C:\Program Files\gs\gs10.05.0\bin" >> $env:GITHUB_PATH # Install extra test images xcopy /S /Y Tests\test-images\* Tests\images From db30ef74232af617b331e2995cc25ac039def106 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 19:49:03 +0000 Subject: [PATCH 08/10] Update dependency cibuildwheel to v2.23.1 --- .ci/requirements-cibw.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/requirements-cibw.txt b/.ci/requirements-cibw.txt index 2fd3eb6ff..f2109ed61 100644 --- a/.ci/requirements-cibw.txt +++ b/.ci/requirements-cibw.txt @@ -1 +1 @@ -cibuildwheel==2.23.0 +cibuildwheel==2.23.1 From 9953256bbf324458b4a7c4e5d070e5e1c4add0dd Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sun, 16 Mar 2025 22:12:14 +1100 Subject: [PATCH 09/10] Revert "Use Ubuntu 22.04 for 24.04 ppc64le and s390x" This reverts commit e31441fc41ff54217317b61db395dfc9b5a0dc79. --- .github/workflows/test-docker.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-docker.yml b/.github/workflows/test-docker.yml index da5e191da..0d9033413 100644 --- a/.github/workflows/test-docker.yml +++ b/.github/workflows/test-docker.yml @@ -35,6 +35,10 @@ jobs: matrix: os: ["ubuntu-latest"] docker: [ + # Run slower jobs first to give them a headstart and reduce waiting time + ubuntu-24.04-noble-ppc64le, + ubuntu-24.04-noble-s390x, + # Then run the remainder alpine, amazon-2-amd64, amazon-2023-amd64, @@ -52,13 +56,9 @@ jobs: dockerTag: [main] include: - docker: "ubuntu-24.04-noble-ppc64le" - os: "ubuntu-22.04" qemu-arch: "ppc64le" - dockerTag: main - docker: "ubuntu-24.04-noble-s390x" - os: "ubuntu-22.04" qemu-arch: "s390x" - dockerTag: main - docker: "ubuntu-24.04-noble-arm64v8" os: "ubuntu-24.04-arm" dockerTag: main From 7767e83e6c40c01f0d61df480153bf9cf6d12a06 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sun, 16 Mar 2025 22:24:13 +1100 Subject: [PATCH 10/10] Use action to setup qemu --- .github/workflows/test-docker.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-docker.yml b/.github/workflows/test-docker.yml index 0d9033413..25aef55fb 100644 --- a/.github/workflows/test-docker.yml +++ b/.github/workflows/test-docker.yml @@ -75,8 +75,9 @@ jobs: - name: Set up QEMU if: "matrix.qemu-arch" - run: | - docker run --rm --privileged aptman/qus -s -- -p ${{ matrix.qemu-arch }} + uses: docker/setup-qemu-action@v3 + with: + platforms: ${{ matrix.qemu-arch }} - name: Docker pull run: |