mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-09-24 13:07:00 +03:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
6216187fb6
commit
29c4469e30
|
@ -179,7 +179,6 @@ class TestImagingCoreResampleAccuracy:
|
||||||
for channel in case.split():
|
for channel in case.split():
|
||||||
self.check_case(channel, self.make_sample(data, (10, 10)))
|
self.check_case(channel, self.make_sample(data, (10, 10)))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("mode", ("RGBX", "RGB", "La", "L"))
|
@pytest.mark.parametrize("mode", ("RGBX", "RGB", "La", "L"))
|
||||||
def test_enlarge_box(self, mode: str) -> None:
|
def test_enlarge_box(self, mode: str) -> None:
|
||||||
case = self.make_case(mode, (2, 2), 0xE1)
|
case = self.make_case(mode, (2, 2), 0xE1)
|
||||||
|
@ -341,7 +340,9 @@ class TestCoreResampleAlphaCorrect:
|
||||||
self.run_levels_case(case.resize((512, 32), Image.Resampling.HAMMING))
|
self.run_levels_case(case.resize((512, 32), Image.Resampling.HAMMING))
|
||||||
self.run_levels_case(case.resize((512, 32), Image.Resampling.BICUBIC))
|
self.run_levels_case(case.resize((512, 32), Image.Resampling.BICUBIC))
|
||||||
self.run_levels_case(case.resize((512, 32), Image.Resampling.LANCZOS))
|
self.run_levels_case(case.resize((512, 32), Image.Resampling.LANCZOS))
|
||||||
self.run_levels_case(case.resize((512, 32), Image.Resampling.MAGIC_KERNEL_SHARP_2021))
|
self.run_levels_case(
|
||||||
|
case.resize((512, 32), Image.Resampling.MAGIC_KERNEL_SHARP_2021)
|
||||||
|
)
|
||||||
|
|
||||||
@pytest.mark.xfail(reason="Current implementation isn't precise enough")
|
@pytest.mark.xfail(reason="Current implementation isn't precise enough")
|
||||||
def test_levels_la(self) -> None:
|
def test_levels_la(self) -> None:
|
||||||
|
@ -351,7 +352,9 @@ class TestCoreResampleAlphaCorrect:
|
||||||
self.run_levels_case(case.resize((512, 32), Image.Resampling.HAMMING))
|
self.run_levels_case(case.resize((512, 32), Image.Resampling.HAMMING))
|
||||||
self.run_levels_case(case.resize((512, 32), Image.Resampling.BICUBIC))
|
self.run_levels_case(case.resize((512, 32), Image.Resampling.BICUBIC))
|
||||||
self.run_levels_case(case.resize((512, 32), Image.Resampling.LANCZOS))
|
self.run_levels_case(case.resize((512, 32), Image.Resampling.LANCZOS))
|
||||||
self.run_levels_case(case.resize((512, 32), Image.Resampling.MAGIC_KERNEL_SHARP_2021))
|
self.run_levels_case(
|
||||||
|
case.resize((512, 32), Image.Resampling.MAGIC_KERNEL_SHARP_2021)
|
||||||
|
)
|
||||||
|
|
||||||
def make_dirty_case(
|
def make_dirty_case(
|
||||||
self, mode: str, clean_pixel: tuple[int, ...], dirty_pixel: tuple[int, ...]
|
self, mode: str, clean_pixel: tuple[int, ...], dirty_pixel: tuple[int, ...]
|
||||||
|
@ -395,7 +398,8 @@ class TestCoreResampleAlphaCorrect:
|
||||||
case.resize((20, 20), Image.Resampling.LANCZOS), (255, 255, 0)
|
case.resize((20, 20), Image.Resampling.LANCZOS), (255, 255, 0)
|
||||||
)
|
)
|
||||||
self.run_dirty_case(
|
self.run_dirty_case(
|
||||||
case.resize((20, 20), Image.Resampling.MAGIC_KERNEL_SHARP_2021), (255, 255, 0)
|
case.resize((20, 20), Image.Resampling.MAGIC_KERNEL_SHARP_2021),
|
||||||
|
(255, 255, 0),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_dirty_pixels_la(self) -> None:
|
def test_dirty_pixels_la(self) -> None:
|
||||||
|
@ -405,7 +409,9 @@ class TestCoreResampleAlphaCorrect:
|
||||||
self.run_dirty_case(case.resize((20, 20), Image.Resampling.HAMMING), (255,))
|
self.run_dirty_case(case.resize((20, 20), Image.Resampling.HAMMING), (255,))
|
||||||
self.run_dirty_case(case.resize((20, 20), Image.Resampling.BICUBIC), (255,))
|
self.run_dirty_case(case.resize((20, 20), Image.Resampling.BICUBIC), (255,))
|
||||||
self.run_dirty_case(case.resize((20, 20), Image.Resampling.LANCZOS), (255,))
|
self.run_dirty_case(case.resize((20, 20), Image.Resampling.LANCZOS), (255,))
|
||||||
self.run_dirty_case(case.resize((20, 20), Image.Resampling.MAGIC_KERNEL_SHARP_2021), (255,))
|
self.run_dirty_case(
|
||||||
|
case.resize((20, 20), Image.Resampling.MAGIC_KERNEL_SHARP_2021), (255,)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestCoreResamplePasses:
|
class TestCoreResamplePasses:
|
||||||
|
|
|
@ -2259,7 +2259,10 @@ class Image:
|
||||||
for filter in (
|
for filter in (
|
||||||
(Resampling.NEAREST, "Image.Resampling.NEAREST"),
|
(Resampling.NEAREST, "Image.Resampling.NEAREST"),
|
||||||
(Resampling.LANCZOS, "Image.Resampling.LANCZOS"),
|
(Resampling.LANCZOS, "Image.Resampling.LANCZOS"),
|
||||||
(Resampling.MAGIC_KERNEL_SHARP_2021, "Image.Resampling.MAGIC_KERNEL_SHARP_2021"),
|
(
|
||||||
|
Resampling.MAGIC_KERNEL_SHARP_2021,
|
||||||
|
"Image.Resampling.MAGIC_KERNEL_SHARP_2021",
|
||||||
|
),
|
||||||
(Resampling.BILINEAR, "Image.Resampling.BILINEAR"),
|
(Resampling.BILINEAR, "Image.Resampling.BILINEAR"),
|
||||||
(Resampling.BICUBIC, "Image.Resampling.BICUBIC"),
|
(Resampling.BICUBIC, "Image.Resampling.BICUBIC"),
|
||||||
(Resampling.BOX, "Image.Resampling.BOX"),
|
(Resampling.BOX, "Image.Resampling.BOX"),
|
||||||
|
@ -2930,7 +2933,12 @@ class Image:
|
||||||
Resampling.BILINEAR,
|
Resampling.BILINEAR,
|
||||||
Resampling.BICUBIC,
|
Resampling.BICUBIC,
|
||||||
):
|
):
|
||||||
if resample in (Resampling.BOX, Resampling.HAMMING, Resampling.LANCZOS, Resampling.MAGIC_KERNEL_SHARP_2021):
|
if resample in (
|
||||||
|
Resampling.BOX,
|
||||||
|
Resampling.HAMMING,
|
||||||
|
Resampling.LANCZOS,
|
||||||
|
Resampling.MAGIC_KERNEL_SHARP_2021,
|
||||||
|
):
|
||||||
unusable: dict[int, str] = {
|
unusable: dict[int, str] = {
|
||||||
Resampling.BOX: "Image.Resampling.BOX",
|
Resampling.BOX: "Image.Resampling.BOX",
|
||||||
Resampling.HAMMING: "Image.Resampling.HAMMING",
|
Resampling.HAMMING: "Image.Resampling.HAMMING",
|
||||||
|
|
|
@ -83,7 +83,7 @@ static inline double
|
||||||
magic_kernel_sharp_2021_filter(double x) {
|
magic_kernel_sharp_2021_filter(double x) {
|
||||||
x = fabs(x);
|
x = fabs(x);
|
||||||
if (x < 0.5) {
|
if (x < 0.5) {
|
||||||
return 577.0 / 576.0 - 239.0 / 144.0 * x *x;
|
return 577.0 / 576.0 - 239.0 / 144.0 * x * x;
|
||||||
}
|
}
|
||||||
if (x < 1.5) {
|
if (x < 1.5) {
|
||||||
return 35.0 / 36.0 * (x - 1.0) * (x - 239.0 / 140.0);
|
return 35.0 / 36.0 * (x - 1.0) * (x - 239.0 / 140.0);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user