mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Merge branch 'main' into ImageOps.contain-function-issue-in-finding-new-size
This commit is contained in:
commit
192aae9ddd
|
@ -37,6 +37,7 @@ def helper_save_as_pdf(tmp_path, mode, **kwargs):
|
||||||
return outfile
|
return outfile
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.valgrind_known_error(reason="Temporary skip")
|
||||||
def test_monochrome(tmp_path):
|
def test_monochrome(tmp_path):
|
||||||
# Arrange
|
# Arrange
|
||||||
mode = "1"
|
mode = "1"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import pytest
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from .helper import CachedProperty, assert_image_equal
|
from .helper import CachedProperty, assert_image_equal
|
||||||
|
@ -101,226 +103,226 @@ class TestImagingPaste:
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_image_solid(self):
|
@pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"])
|
||||||
for mode in ("RGBA", "RGB", "L"):
|
def test_image_solid(self, mode):
|
||||||
im = Image.new(mode, (200, 200), "red")
|
im = Image.new(mode, (200, 200), "red")
|
||||||
im2 = getattr(self, "gradient_" + mode)
|
im2 = getattr(self, "gradient_" + mode)
|
||||||
|
|
||||||
im.paste(im2, (12, 23))
|
im.paste(im2, (12, 23))
|
||||||
|
|
||||||
im = im.crop((12, 23, im2.width + 12, im2.height + 23))
|
im = im.crop((12, 23, im2.width + 12, im2.height + 23))
|
||||||
assert_image_equal(im, im2)
|
assert_image_equal(im, im2)
|
||||||
|
|
||||||
def test_image_mask_1(self):
|
@pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"])
|
||||||
for mode in ("RGBA", "RGB", "L"):
|
def test_image_mask_1(self, mode):
|
||||||
im = Image.new(mode, (200, 200), "white")
|
im = Image.new(mode, (200, 200), "white")
|
||||||
im2 = getattr(self, "gradient_" + mode)
|
im2 = getattr(self, "gradient_" + mode)
|
||||||
|
|
||||||
self.assert_9points_paste(
|
self.assert_9points_paste(
|
||||||
im,
|
im,
|
||||||
im2,
|
im2,
|
||||||
self.mask_1,
|
self.mask_1,
|
||||||
[
|
[
|
||||||
(255, 255, 255, 255),
|
(255, 255, 255, 255),
|
||||||
(255, 255, 255, 255),
|
(255, 255, 255, 255),
|
||||||
(127, 254, 127, 0),
|
(127, 254, 127, 0),
|
||||||
(255, 255, 255, 255),
|
(255, 255, 255, 255),
|
||||||
(255, 255, 255, 255),
|
(255, 255, 255, 255),
|
||||||
(191, 190, 63, 64),
|
(191, 190, 63, 64),
|
||||||
(127, 0, 127, 254),
|
(127, 0, 127, 254),
|
||||||
(191, 64, 63, 190),
|
(191, 64, 63, 190),
|
||||||
(255, 255, 255, 255),
|
(255, 255, 255, 255),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_image_mask_L(self):
|
@pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"])
|
||||||
for mode in ("RGBA", "RGB", "L"):
|
def test_image_mask_L(self, mode):
|
||||||
im = Image.new(mode, (200, 200), "white")
|
im = Image.new(mode, (200, 200), "white")
|
||||||
im2 = getattr(self, "gradient_" + mode)
|
im2 = getattr(self, "gradient_" + mode)
|
||||||
|
|
||||||
self.assert_9points_paste(
|
self.assert_9points_paste(
|
||||||
im,
|
im,
|
||||||
im2,
|
im2,
|
||||||
self.mask_L,
|
self.mask_L,
|
||||||
[
|
[
|
||||||
(128, 191, 255, 191),
|
(128, 191, 255, 191),
|
||||||
(208, 239, 239, 208),
|
(208, 239, 239, 208),
|
||||||
(255, 255, 255, 255),
|
(255, 255, 255, 255),
|
||||||
(112, 111, 206, 207),
|
(112, 111, 206, 207),
|
||||||
(192, 191, 191, 191),
|
(192, 191, 191, 191),
|
||||||
(239, 239, 207, 207),
|
(239, 239, 207, 207),
|
||||||
(128, 1, 128, 254),
|
(128, 1, 128, 254),
|
||||||
(207, 113, 112, 207),
|
(207, 113, 112, 207),
|
||||||
(255, 191, 128, 191),
|
(255, 191, 128, 191),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_image_mask_LA(self):
|
@pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"])
|
||||||
for mode in ("RGBA", "RGB", "L"):
|
def test_image_mask_LA(self, mode):
|
||||||
im = Image.new(mode, (200, 200), "white")
|
im = Image.new(mode, (200, 200), "white")
|
||||||
im2 = getattr(self, "gradient_" + mode)
|
im2 = getattr(self, "gradient_" + mode)
|
||||||
|
|
||||||
self.assert_9points_paste(
|
self.assert_9points_paste(
|
||||||
im,
|
im,
|
||||||
im2,
|
im2,
|
||||||
self.gradient_LA,
|
self.gradient_LA,
|
||||||
[
|
[
|
||||||
(128, 191, 255, 191),
|
(128, 191, 255, 191),
|
||||||
(112, 207, 206, 111),
|
(112, 207, 206, 111),
|
||||||
(128, 254, 128, 1),
|
(128, 254, 128, 1),
|
||||||
(208, 208, 239, 239),
|
(208, 208, 239, 239),
|
||||||
(192, 191, 191, 191),
|
(192, 191, 191, 191),
|
||||||
(207, 207, 112, 113),
|
(207, 207, 112, 113),
|
||||||
(255, 255, 255, 255),
|
(255, 255, 255, 255),
|
||||||
(239, 207, 207, 239),
|
(239, 207, 207, 239),
|
||||||
(255, 191, 128, 191),
|
(255, 191, 128, 191),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_image_mask_RGBA(self):
|
@pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"])
|
||||||
for mode in ("RGBA", "RGB", "L"):
|
def test_image_mask_RGBA(self, mode):
|
||||||
im = Image.new(mode, (200, 200), "white")
|
im = Image.new(mode, (200, 200), "white")
|
||||||
im2 = getattr(self, "gradient_" + mode)
|
im2 = getattr(self, "gradient_" + mode)
|
||||||
|
|
||||||
self.assert_9points_paste(
|
self.assert_9points_paste(
|
||||||
im,
|
im,
|
||||||
im2,
|
im2,
|
||||||
self.gradient_RGBA,
|
self.gradient_RGBA,
|
||||||
[
|
[
|
||||||
(128, 191, 255, 191),
|
(128, 191, 255, 191),
|
||||||
(208, 239, 239, 208),
|
(208, 239, 239, 208),
|
||||||
(255, 255, 255, 255),
|
(255, 255, 255, 255),
|
||||||
(112, 111, 206, 207),
|
(112, 111, 206, 207),
|
||||||
(192, 191, 191, 191),
|
(192, 191, 191, 191),
|
||||||
(239, 239, 207, 207),
|
(239, 239, 207, 207),
|
||||||
(128, 1, 128, 254),
|
(128, 1, 128, 254),
|
||||||
(207, 113, 112, 207),
|
(207, 113, 112, 207),
|
||||||
(255, 191, 128, 191),
|
(255, 191, 128, 191),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_image_mask_RGBa(self):
|
@pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"])
|
||||||
for mode in ("RGBA", "RGB", "L"):
|
def test_image_mask_RGBa(self, mode):
|
||||||
im = Image.new(mode, (200, 200), "white")
|
im = Image.new(mode, (200, 200), "white")
|
||||||
im2 = getattr(self, "gradient_" + mode)
|
im2 = getattr(self, "gradient_" + mode)
|
||||||
|
|
||||||
self.assert_9points_paste(
|
self.assert_9points_paste(
|
||||||
im,
|
im,
|
||||||
im2,
|
im2,
|
||||||
self.gradient_RGBa,
|
self.gradient_RGBa,
|
||||||
[
|
[
|
||||||
(128, 255, 126, 255),
|
(128, 255, 126, 255),
|
||||||
(0, 127, 126, 255),
|
(0, 127, 126, 255),
|
||||||
(126, 253, 126, 255),
|
(126, 253, 126, 255),
|
||||||
(128, 127, 254, 255),
|
(128, 127, 254, 255),
|
||||||
(0, 255, 254, 255),
|
(0, 255, 254, 255),
|
||||||
(126, 125, 254, 255),
|
(126, 125, 254, 255),
|
||||||
(128, 1, 128, 255),
|
(128, 1, 128, 255),
|
||||||
(0, 129, 128, 255),
|
(0, 129, 128, 255),
|
||||||
(126, 255, 128, 255),
|
(126, 255, 128, 255),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_color_solid(self):
|
@pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"])
|
||||||
for mode in ("RGBA", "RGB", "L"):
|
def test_color_solid(self, mode):
|
||||||
im = Image.new(mode, (200, 200), "black")
|
im = Image.new(mode, (200, 200), "black")
|
||||||
|
|
||||||
rect = (12, 23, 128 + 12, 128 + 23)
|
rect = (12, 23, 128 + 12, 128 + 23)
|
||||||
im.paste("white", rect)
|
im.paste("white", rect)
|
||||||
|
|
||||||
hist = im.crop(rect).histogram()
|
hist = im.crop(rect).histogram()
|
||||||
while hist:
|
while hist:
|
||||||
head, hist = hist[:256], hist[256:]
|
head, hist = hist[:256], hist[256:]
|
||||||
assert head[255] == 128 * 128
|
assert head[255] == 128 * 128
|
||||||
assert sum(head[:255]) == 0
|
assert sum(head[:255]) == 0
|
||||||
|
|
||||||
def test_color_mask_1(self):
|
@pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"])
|
||||||
for mode in ("RGBA", "RGB", "L"):
|
def test_color_mask_1(self, mode):
|
||||||
im = Image.new(mode, (200, 200), (50, 60, 70, 80)[: len(mode)])
|
im = Image.new(mode, (200, 200), (50, 60, 70, 80)[: len(mode)])
|
||||||
color = (10, 20, 30, 40)[: len(mode)]
|
color = (10, 20, 30, 40)[: len(mode)]
|
||||||
|
|
||||||
self.assert_9points_paste(
|
self.assert_9points_paste(
|
||||||
im,
|
im,
|
||||||
color,
|
color,
|
||||||
self.mask_1,
|
self.mask_1,
|
||||||
[
|
[
|
||||||
(50, 60, 70, 80),
|
(50, 60, 70, 80),
|
||||||
(50, 60, 70, 80),
|
(50, 60, 70, 80),
|
||||||
(10, 20, 30, 40),
|
(10, 20, 30, 40),
|
||||||
(50, 60, 70, 80),
|
(50, 60, 70, 80),
|
||||||
(50, 60, 70, 80),
|
(50, 60, 70, 80),
|
||||||
(10, 20, 30, 40),
|
(10, 20, 30, 40),
|
||||||
(10, 20, 30, 40),
|
(10, 20, 30, 40),
|
||||||
(10, 20, 30, 40),
|
(10, 20, 30, 40),
|
||||||
(50, 60, 70, 80),
|
(50, 60, 70, 80),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_color_mask_L(self):
|
@pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"])
|
||||||
for mode in ("RGBA", "RGB", "L"):
|
def test_color_mask_L(self, mode):
|
||||||
im = getattr(self, "gradient_" + mode).copy()
|
im = getattr(self, "gradient_" + mode).copy()
|
||||||
color = "white"
|
color = "white"
|
||||||
|
|
||||||
self.assert_9points_paste(
|
self.assert_9points_paste(
|
||||||
im,
|
im,
|
||||||
color,
|
color,
|
||||||
self.mask_L,
|
self.mask_L,
|
||||||
[
|
[
|
||||||
(127, 191, 254, 191),
|
(127, 191, 254, 191),
|
||||||
(111, 207, 206, 110),
|
(111, 207, 206, 110),
|
||||||
(127, 254, 127, 0),
|
(127, 254, 127, 0),
|
||||||
(207, 207, 239, 239),
|
(207, 207, 239, 239),
|
||||||
(191, 191, 190, 191),
|
(191, 191, 190, 191),
|
||||||
(207, 206, 111, 112),
|
(207, 206, 111, 112),
|
||||||
(254, 254, 254, 255),
|
(254, 254, 254, 255),
|
||||||
(239, 206, 206, 238),
|
(239, 206, 206, 238),
|
||||||
(254, 191, 127, 191),
|
(254, 191, 127, 191),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_color_mask_RGBA(self):
|
@pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"])
|
||||||
for mode in ("RGBA", "RGB", "L"):
|
def test_color_mask_RGBA(self, mode):
|
||||||
im = getattr(self, "gradient_" + mode).copy()
|
im = getattr(self, "gradient_" + mode).copy()
|
||||||
color = "white"
|
color = "white"
|
||||||
|
|
||||||
self.assert_9points_paste(
|
self.assert_9points_paste(
|
||||||
im,
|
im,
|
||||||
color,
|
color,
|
||||||
self.gradient_RGBA,
|
self.gradient_RGBA,
|
||||||
[
|
[
|
||||||
(127, 191, 254, 191),
|
(127, 191, 254, 191),
|
||||||
(111, 207, 206, 110),
|
(111, 207, 206, 110),
|
||||||
(127, 254, 127, 0),
|
(127, 254, 127, 0),
|
||||||
(207, 207, 239, 239),
|
(207, 207, 239, 239),
|
||||||
(191, 191, 190, 191),
|
(191, 191, 190, 191),
|
||||||
(207, 206, 111, 112),
|
(207, 206, 111, 112),
|
||||||
(254, 254, 254, 255),
|
(254, 254, 254, 255),
|
||||||
(239, 206, 206, 238),
|
(239, 206, 206, 238),
|
||||||
(254, 191, 127, 191),
|
(254, 191, 127, 191),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_color_mask_RGBa(self):
|
@pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"])
|
||||||
for mode in ("RGBA", "RGB", "L"):
|
def test_color_mask_RGBa(self, mode):
|
||||||
im = getattr(self, "gradient_" + mode).copy()
|
im = getattr(self, "gradient_" + mode).copy()
|
||||||
color = "white"
|
color = "white"
|
||||||
|
|
||||||
self.assert_9points_paste(
|
self.assert_9points_paste(
|
||||||
im,
|
im,
|
||||||
color,
|
color,
|
||||||
self.gradient_RGBa,
|
self.gradient_RGBa,
|
||||||
[
|
[
|
||||||
(255, 63, 126, 63),
|
(255, 63, 126, 63),
|
||||||
(47, 143, 142, 46),
|
(47, 143, 142, 46),
|
||||||
(126, 253, 126, 255),
|
(126, 253, 126, 255),
|
||||||
(15, 15, 47, 47),
|
(15, 15, 47, 47),
|
||||||
(63, 63, 62, 63),
|
(63, 63, 62, 63),
|
||||||
(142, 141, 46, 47),
|
(142, 141, 46, 47),
|
||||||
(255, 255, 255, 0),
|
(255, 255, 255, 0),
|
||||||
(48, 15, 15, 47),
|
(48, 15, 15, 47),
|
||||||
(126, 63, 255, 63),
|
(126, 63, 255, 63),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_different_sizes(self):
|
def test_different_sizes(self):
|
||||||
im = Image.new("RGB", (100, 100))
|
im = Image.new("RGB", (100, 100))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# install libimagequant
|
# install libimagequant
|
||||||
|
|
||||||
archive=libimagequant-4.0.1
|
archive=libimagequant-4.0.2
|
||||||
|
|
||||||
./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz
|
./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ Many of Pillow's features require external libraries:
|
||||||
|
|
||||||
* **libimagequant** provides improved color quantization
|
* **libimagequant** provides improved color quantization
|
||||||
|
|
||||||
* Pillow has been tested with libimagequant **2.6-4.0.1**
|
* Pillow has been tested with libimagequant **2.6-4.0.2**
|
||||||
* Libimagequant is licensed GPLv3, which is more restrictive than
|
* Libimagequant is licensed GPLv3, which is more restrictive than
|
||||||
the Pillow license, therefore we will not be distributing binaries
|
the Pillow license, therefore we will not be distributing binaries
|
||||||
with libimagequant support enabled.
|
with libimagequant support enabled.
|
||||||
|
|
|
@ -226,21 +226,21 @@ deps = {
|
||||||
"filename": "lcms2-2.13.1.tar.gz",
|
"filename": "lcms2-2.13.1.tar.gz",
|
||||||
"dir": "lcms2-2.13.1",
|
"dir": "lcms2-2.13.1",
|
||||||
"patch": {
|
"patch": {
|
||||||
r"Projects\VC2019\lcms2_static\lcms2_static.vcxproj": {
|
r"Projects\VC2022\lcms2_static\lcms2_static.vcxproj": {
|
||||||
# default is /MD for x86 and /MT for x64, we need /MD always
|
# default is /MD for x86 and /MT for x64, we need /MD always
|
||||||
"<RuntimeLibrary>MultiThreaded</RuntimeLibrary>": "<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>", # noqa: E501
|
"<RuntimeLibrary>MultiThreaded</RuntimeLibrary>": "<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>", # noqa: E501
|
||||||
# retarget to default toolset (selected by vcvarsall.bat)
|
# retarget to default toolset (selected by vcvarsall.bat)
|
||||||
"<PlatformToolset>v142</PlatformToolset>": "<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>", # noqa: E501
|
"<PlatformToolset>v143</PlatformToolset>": "<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>", # noqa: E501
|
||||||
# retarget to latest (selected by vcvarsall.bat)
|
# retarget to latest (selected by vcvarsall.bat)
|
||||||
"<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>": "<WindowsTargetPlatformVersion>$(WindowsSDKVersion)</WindowsTargetPlatformVersion>", # noqa: E501
|
"<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>": "<WindowsTargetPlatformVersion>$(WindowsSDKVersion)</WindowsTargetPlatformVersion>", # noqa: E501
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"build": [
|
"build": [
|
||||||
cmd_rmdir("Lib"),
|
cmd_rmdir("Lib"),
|
||||||
cmd_rmdir(r"Projects\VC2019\Release"),
|
cmd_rmdir(r"Projects\VC2022\Release"),
|
||||||
cmd_msbuild(r"Projects\VC2019\lcms2.sln", "Release", "Clean"),
|
cmd_msbuild(r"Projects\VC2022\lcms2.sln", "Release", "Clean"),
|
||||||
cmd_msbuild(
|
cmd_msbuild(
|
||||||
r"Projects\VC2019\lcms2.sln", "Release", "lcms2_static:Rebuild"
|
r"Projects\VC2022\lcms2.sln", "Release", "lcms2_static:Rebuild"
|
||||||
),
|
),
|
||||||
cmd_xcopy("include", "{inc_dir}"),
|
cmd_xcopy("include", "{inc_dir}"),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user