From 78d70e5b11a7e1ab0be0c7d0777bd42794535876 Mon Sep 17 00:00:00 2001 From: daquexian Date: Sat, 16 Nov 2019 21:57:50 +0800 Subject: [PATCH 01/12] Update the out-dated termux.sh Termux does not have -dev packages any more and pkg install -y instead of pkg -y install should be used --- depends/termux.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/depends/termux.sh b/depends/termux.sh index f117790c5..1acc09c44 100755 --- a/depends/termux.sh +++ b/depends/termux.sh @@ -1,5 +1,5 @@ #!/bin/sh -pkg -y install python python-dev ndk-sysroot clang make \ - libjpeg-turbo-dev +pkg install -y python ndk-sysroot clang make \ + libjpeg-turbo From 2537e8d23ed46c6d0b04fbf2746ad05cad0c48ef Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 30 Nov 2019 07:52:31 +1100 Subject: [PATCH 02/12] Updated Termux command [ci skip] --- docs/installation.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/installation.rst b/docs/installation.rst index 4ccc47ae4..d11e7c0f7 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -362,8 +362,8 @@ Building on Android Basic Android support has been added for compilation within the Termux environment. The dependencies can be installed by:: - $ pkg -y install python python-dev ndk-sysroot clang make \ - libjpeg-turbo-dev + $ pkg install -y python ndk-sysroot clang make \ + libjpeg-turbo This has been tested within the Termux app on ChromeOS, on x86. From 4b863b3cd2f274edae52ec5e5c8d2df1543e8568 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 7 Dec 2019 21:57:57 +1100 Subject: [PATCH 03/12] Invert Python version support table [ci skip] --- docs/installation.rst | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/installation.rst b/docs/installation.rst index 36ed805fe..cabc8e5d4 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -15,24 +15,25 @@ Notes .. note:: Pillow is supported on the following Python versions + +-------------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -|**Python** |**2.4**|**2.5**|**2.6**|**2.7**|**3.2**|**3.3**|**3.4**|**3.5**|**3.6**|**3.7**|**3.8**| +|**Python** |**3.8**|**3.7**|**3.6**|**3.5**|**3.4**|**3.3**|**3.2**|**2.7**|**2.6**|**2.5**|**2.4**| +-------------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -|Pillow < 2 | Yes | Yes | Yes | Yes | | | | | | | | +|Pillow >= 7 | Yes | Yes | Yes | Yes | | | | | | | | +-------------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -|Pillow 2 - 3 | | | Yes | Yes | Yes | Yes | Yes | Yes | | | | +|Pillow 6.2.1 | Yes | Yes | Yes | Yes | | | | Yes | | | | +-------------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -|Pillow 4 | | | | Yes | | Yes | Yes | Yes | Yes | | | +|Pillow 6.0 - 6.2.0 | | Yes | Yes | Yes | | | | Yes | | | | +-------------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -|Pillow 5.0 - 5.1 | | | | Yes | | | Yes | Yes | Yes | | | +|Pillow 5.2 - 5.4 | | Yes | Yes | Yes | Yes | | | Yes | | | | +-------------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -|Pillow 5.2 - 5.4 | | | | Yes | | | Yes | Yes | Yes | Yes | | +|Pillow 5.0 - 5.1 | | | Yes | Yes | Yes | | | Yes | | | | +-------------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -|Pillow 6.0 - 6.2.0 | | | | Yes | | | | Yes | Yes | Yes | | +|Pillow 4 | | | Yes | Yes | Yes | Yes | | Yes | | | | +-------------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -|Pillow 6.2.1 | | | | Yes | | | | Yes | Yes | Yes | Yes | +|Pillow 2 - 3 | | | | Yes | Yes | Yes | Yes | Yes | Yes | | | +-------------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -|Pillow >= 7 | | | | | | | | Yes | Yes | Yes | Yes | +|Pillow < 2 | | | | | | | | Yes | Yes | Yes | Yes | +-------------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ Basic Installation From 791d1a2846e28955e964cfa38ac4632fc457fa30 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 7 Dec 2019 20:07:27 +0300 Subject: [PATCH 04/12] Better thumbnail aspect ratio preservation --- Tests/test_image_thumbnail.py | 40 ++++++++++++++++++++--------------- src/PIL/Image.py | 8 +++---- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/Tests/test_image_thumbnail.py b/Tests/test_image_thumbnail.py index d1224f075..30fe25557 100644 --- a/Tests/test_image_thumbnail.py +++ b/Tests/test_image_thumbnail.py @@ -5,37 +5,43 @@ from .helper import PillowTestCase, hopper class TestImageThumbnail(PillowTestCase): def test_sanity(self): - im = hopper() - im.thumbnail((100, 100)) + self.assertIsNone(im.thumbnail((100, 100))) - self.assert_image(im, im.mode, (100, 100)) + self.assertEqual(im.size, (100, 100)) def test_aspect(self): - - im = hopper() + im = Image.new("L", (128, 128)) im.thumbnail((100, 100)) - self.assert_image(im, im.mode, (100, 100)) + self.assertEqual(im.size, (100, 100)) - im = hopper().resize((128, 256)) + im = Image.new("L", (128, 256)) im.thumbnail((100, 100)) - self.assert_image(im, im.mode, (50, 100)) + self.assertEqual(im.size, (50, 100)) - im = hopper().resize((128, 256)) + im = Image.new("L", (128, 256)) im.thumbnail((50, 100)) - self.assert_image(im, im.mode, (50, 100)) + self.assertEqual(im.size, (50, 100)) - im = hopper().resize((256, 128)) + im = Image.new("L", (256, 128)) im.thumbnail((100, 100)) - self.assert_image(im, im.mode, (100, 50)) + self.assertEqual(im.size, (100, 50)) - im = hopper().resize((256, 128)) + im = Image.new("L", (256, 128)) im.thumbnail((100, 50)) - self.assert_image(im, im.mode, (100, 50)) + self.assertEqual(im.size, (100, 50)) - im = hopper().resize((128, 128)) + im = Image.new("L", (128, 128)) im.thumbnail((100, 100)) - self.assert_image(im, im.mode, (100, 100)) + self.assertEqual(im.size, (100, 100)) + + im = Image.new("L", (256, 162)) # ratio is 1.5802469136 + im.thumbnail((33, 33)) + self.assertEqual(im.size, (33, 21)) # ratio is 1.5714285714 + + im = Image.new("L", (162, 256)) # ratio is 0.6328125 + im.thumbnail((33, 33)) + self.assertEqual(im.size, (21, 33)) # ratio is 0.6363636364 def test_no_resize(self): # Check that draft() can resize the image to the destination size @@ -46,4 +52,4 @@ class TestImageThumbnail(PillowTestCase): # Test thumbnail(), where only draft() is necessary to resize the image with Image.open("Tests/images/hopper.jpg") as im: im.thumbnail((64, 64)) - self.assert_image(im, im.mode, (64, 64)) + self.assertEqual(im.size, (64, 64)) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 96ec314bc..613b3a361 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -2137,11 +2137,11 @@ class Image: # preserve aspect ratio x, y = self.size if x > size[0]: - y = int(max(y * size[0] / x, 1)) - x = int(size[0]) + y = max(round(y * size[0] / x), 1) + x = size[0] if y > size[1]: - x = int(max(x * size[1] / y, 1)) - y = int(size[1]) + x = max(round(x * size[1] / y), 1) + y = size[1] size = x, y if size == self.size: From c22a5ffae7e02f31242fcc705696eec6f55caac7 Mon Sep 17 00:00:00 2001 From: Hugo Date: Mon, 9 Dec 2019 22:35:31 +0200 Subject: [PATCH 05/12] Print some basic system information for the logs --- .github/workflows/lint.yml | 3 +++ .github/workflows/system-info.py | 24 ++++++++++++++++++++++++ .github/workflows/test-docker.yml | 3 +++ .github/workflows/test-windows.yml | 3 +++ .github/workflows/test.yml | 3 +++ 5 files changed, 36 insertions(+) create mode 100644 .github/workflows/system-info.py diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 195ea3865..576b88414 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,6 +20,9 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Build system information + run: python .github/workflows/system-info.py + - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/system-info.py b/.github/workflows/system-info.py new file mode 100644 index 000000000..499935b4d --- /dev/null +++ b/.github/workflows/system-info.py @@ -0,0 +1,24 @@ +""" +Print out some handy system info like Travis CI does. + +This sort of info is missing from GitHub Actions. + +Requested here: +https://github.com/actions/virtual-environments/issues/79 +""" +import os +import platform +import sys + +print("Build system information") +print() + +print("sys.version\t\t", sys.version.split("\n")) +print("os.name\t\t\t", os.name) +print("sys.platform\t\t", sys.platform) +print("platform.system()\t", platform.system()) +print("platform.machine()\t", platform.machine()) +print("platform.platform()\t", platform.platform()) +print("platform.version()\t", platform.version()) +print("platform.uname()\t", platform.uname()) +print("platform.mac_ver()\t", platform.mac_ver()) diff --git a/.github/workflows/test-docker.yml b/.github/workflows/test-docker.yml index 4121eb5e9..3e8a416a5 100644 --- a/.github/workflows/test-docker.yml +++ b/.github/workflows/test-docker.yml @@ -29,6 +29,9 @@ jobs: steps: - uses: actions/checkout@v1 + - name: Build system information + run: python .github/workflows/system-info.py + - name: Docker pull run: | docker pull pythonpillow/${{ matrix.docker }}:${{ matrix.dockerTag }} diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 00cae9bc2..e0c55bc1a 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -70,6 +70,9 @@ jobs: python-version: ${{ matrix.python-version }} architecture: ${{ matrix.architecture }} + - name: Build system information + run: python .github/workflows/system-info.py + - name: pip install wheel pytest pytest-cov run: | "%pythonLocation%\python.exe" -m pip install wheel pytest pytest-cov diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 69ed445a6..78307b7a1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,6 +55,9 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Build system information + run: python .github/workflows/system-info.py + - name: Install Linux dependencies if: startsWith(matrix.os, 'ubuntu') run: | From 306d6ccfed9a5b983817e4721aabde50661dc3ea Mon Sep 17 00:00:00 2001 From: nulano Date: Mon, 9 Dec 2019 22:48:57 +0100 Subject: [PATCH 06/12] update tested versions table [ci skip] --- docs/installation.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/installation.rst b/docs/installation.rst index 276c4d79e..c51b9c90a 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -187,7 +187,7 @@ Many of Pillow's features require external libraries: libraqm. * libraqm is dynamically loaded in Pillow 5.0.0 and above, so support is available if all the libraries are installed. - * Windows support: Raqm support is currently unsupported on Windows. + * Windows support: Raqm is not included in prebuilt wheels Once you have installed the prerequisites, run:: @@ -408,10 +408,14 @@ These platforms are built and tested for every change. +----------------------------------+--------------------------+-----------------------+ | Ubuntu Linux 16.04 LTS | 3.5, 3.6, 3.7, 3.8, PyPy3|x86-64 | +----------------------------------+--------------------------+-----------------------+ -| Windows Server 2012 R2 | 3.5, 3.6, 3.7, 3.8 |x86, x86-64 | +| Windows Server 2012 R2 | 3.5, 3.8 |x86, x86-64 | | +--------------------------+-----------------------+ | | PyPy3, 3.7/MinGW |x86 | +----------------------------------+--------------------------+-----------------------+ +| Windows Server 2019 | 3.5, 3.6, 3.7, 3.8 |x86, x86-64 | +| +--------------------------+-----------------------+ +| | PyPy3 |x86 | ++----------------------------------+--------------------------+-----------------------+ Other Platforms From 58a476423a6d02c21b213fed15065d7c5d5237e8 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 10 Dec 2019 21:47:18 +1100 Subject: [PATCH 07/12] Updated CHANGES.rst [ci skip] --- CHANGES.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 5af03f281..b4834a8da 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,12 @@ Changelog (Pillow) 7.0.0 (unreleased) ------------------ +- Add La mode packing and unpacking #4248 + [homm] + +- Include tests in coverage reports #4173 + [hugovk] + - Handle broken Photoshop data #4239 [radarhere] From a4dc5740f99ed6060db5e46c4ec4233fc68412e2 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Fri, 13 Dec 2019 15:44:01 +0200 Subject: [PATCH 08/12] Only print Mac version on Mac Co-Authored-By: Andrew Murray <3112309+radarhere@users.noreply.github.com> --- .github/workflows/system-info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/system-info.py b/.github/workflows/system-info.py index 499935b4d..8e840319a 100644 --- a/.github/workflows/system-info.py +++ b/.github/workflows/system-info.py @@ -21,4 +21,5 @@ print("platform.machine()\t", platform.machine()) print("platform.platform()\t", platform.platform()) print("platform.version()\t", platform.version()) print("platform.uname()\t", platform.uname()) -print("platform.mac_ver()\t", platform.mac_ver()) +if sys.platform == "darwin": + print("platform.mac_ver()\t", platform.mac_ver()) From 2fde01cda213eae1399d2d5af66bf1d8186c30e0 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 14 Dec 2019 13:36:07 +1100 Subject: [PATCH 09/12] Updated URL --- .codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codecov.yml b/.codecov.yml index d348345dc..060b2685e 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -3,7 +3,7 @@ codecov: # Avoid "Missing base report" due to committing CHANGES.rst with "[CI skip]" # https://github.com/codecov/support/issues/363 - # https://docs.codecov.io/v4.3.6/docs/comparing-commits + # https://docs.codecov.io/docs/comparing-commits allow_coverage_offsets: true token: 6dafc396-e7f5-4221-a38a-8b07a49fbdae From 7b4ae104f0937f09f4ff433ba45f494ecf85c004 Mon Sep 17 00:00:00 2001 From: Hugo Date: Mon, 16 Dec 2019 15:07:56 +0200 Subject: [PATCH 10/12] Fix malformed table --- docs/handbook/concepts.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/handbook/concepts.rst b/docs/handbook/concepts.rst index 7e782e743..e4a720a08 100644 --- a/docs/handbook/concepts.rst +++ b/docs/handbook/concepts.rst @@ -169,15 +169,15 @@ Filters comparison table | Filter | Downscaling | Upscaling | Performance | | | quality | quality | | +============+=============+===========+=============+ -|``NEAREST`` | | | ⭐⭐⭐⭐⭐ | +|``NEAREST`` | | | ⭐⭐⭐⭐⭐ | +------------+-------------+-----------+-------------+ -|``BOX`` | ⭐ | | ⭐⭐⭐⭐ | +|``BOX`` | ⭐ | | ⭐⭐⭐⭐ | +------------+-------------+-----------+-------------+ -|``BILINEAR``| ⭐ | ⭐ | ⭐⭐⭐ | +|``BILINEAR``| ⭐ | ⭐ | ⭐⭐⭐ | +------------+-------------+-----------+-------------+ -|``HAMMING`` | ⭐⭐ | | ⭐⭐⭐ | +|``HAMMING`` | ⭐⭐ | | ⭐⭐⭐ | +------------+-------------+-----------+-------------+ -|``BICUBIC`` | ⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐ | +|``BICUBIC`` | ⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐ | +------------+-------------+-----------+-------------+ -|``LANCZOS`` | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐ | +|``LANCZOS`` | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐ | +------------+-------------+-----------+-------------+ From c7bef264bc455d191e0540fa8ac67d989438f929 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 17 Dec 2019 06:05:36 +1100 Subject: [PATCH 11/12] Allow thumbnail to accept non-integer size arguments --- Tests/test_image_thumbnail.py | 5 +++++ src/PIL/Image.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Tests/test_image_thumbnail.py b/Tests/test_image_thumbnail.py index 30fe25557..5806e2a08 100644 --- a/Tests/test_image_thumbnail.py +++ b/Tests/test_image_thumbnail.py @@ -43,6 +43,11 @@ class TestImageThumbnail(PillowTestCase): im.thumbnail((33, 33)) self.assertEqual(im.size, (21, 33)) # ratio is 0.6363636364 + def test_float(self): + im = Image.new("L", (128, 128)) + im.thumbnail((99.9, 99.9)) + self.assertEqual(im.size, (100, 100)) + def test_no_resize(self): # Check that draft() can resize the image to the destination size with Image.open("Tests/images/hopper.jpg") as im: diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 613b3a361..981c8c818 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -2138,10 +2138,10 @@ class Image: x, y = self.size if x > size[0]: y = max(round(y * size[0] / x), 1) - x = size[0] + x = round(size[0]) if y > size[1]: x = max(round(x * size[1] / y), 1) - y = size[1] + y = round(size[1]) size = x, y if size == self.size: From 1785cad9315803750078e0ae91857b0fba640a73 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 17 Dec 2019 18:49:52 +1100 Subject: [PATCH 12/12] Updated CHANGES.rst [ci skip] --- CHANGES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index b4834a8da..c1eab0c2e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,9 @@ Changelog (Pillow) 7.0.0 (unreleased) ------------------ +- Better thumbnail aspect ratio preservation #4256 + [homm] + - Add La mode packing and unpacking #4248 [homm]