diff --git a/numpy120.patch b/numpy120.patch deleted file mode 100644 index 6b90d6a..0000000 --- a/numpy120.patch +++ /dev/null @@ -1,69 +0,0 @@ -From fa854ac6b4c2a691a418cfac0eb5a2305731576c Mon Sep 17 00:00:00 2001 -From: "adria.labay" -Date: Wed, 8 Feb 2023 15:40:36 +0100 -Subject: [PATCH] support numpy 1.20 - ---- - ssim/utils.py | 26 ++++++++++++-------------- - 1 file changed, 12 insertions(+), 14 deletions(-) - -Index: pyssim-0.5/ssim/utils.py -=================================================================== ---- pyssim-0.5.orig/ssim/utils.py -+++ pyssim-0.5/ssim/utils.py -@@ -2,31 +2,29 @@ - - from __future__ import absolute_import - --import numpy --from numpy.ma.core import exp -+import numpy as np - import scipy.ndimage - - from ssim.compat import ImageOps - -+ - def convolve_gaussian_2d(image, gaussian_kernel_1d): - """Convolve 2d gaussian.""" -- result = scipy.ndimage.filters.correlate1d( -+ result = scipy.ndimage.correlate1d( - image, gaussian_kernel_1d, axis=0) -- result = scipy.ndimage.filters.correlate1d( -+ return scipy.ndimage.correlate1d( - result, gaussian_kernel_1d, axis=1) -- return result -+ - - def get_gaussian_kernel(gaussian_kernel_width=11, gaussian_kernel_sigma=1.5): - """Generate a gaussian kernel.""" - # 1D Gaussian kernel definition -- gaussian_kernel_1d = numpy.ndarray((gaussian_kernel_width)) -- norm_mu = int(gaussian_kernel_width / 2) -+ gaussian_kernel_1d = np.arange(0, gaussian_kernel_width, 1.) -+ gaussian_kernel_1d -= gaussian_kernel_width / 2 -+ gaussian_kernel_1d = np.exp(-0.5 * gaussian_kernel_1d**2 / -+ gaussian_kernel_sigma**2) -+ return gaussian_kernel_1d / np.sum(gaussian_kernel_1d) - -- # Fill Gaussian kernel -- for i in range(gaussian_kernel_width): -- gaussian_kernel_1d[i] = (exp(-(((i - norm_mu) ** 2)) / -- (2 * (gaussian_kernel_sigma ** 2)))) -- return gaussian_kernel_1d / numpy.sum(gaussian_kernel_1d) - - def to_grayscale(img): - """Convert PIL image to numpy grayscale array and numpy alpha array. -@@ -37,11 +35,11 @@ def to_grayscale(img): - Returns: - (gray, alpha): both numpy arrays. - """ -- gray = numpy.asarray(ImageOps.grayscale(img)).astype(numpy.float) -+ gray = np.asarray(ImageOps.grayscale(img)).astype(float) - - imbands = img.getbands() - alpha = None - if 'A' in imbands: -- alpha = numpy.asarray(img.split()[-1]).astype(numpy.float) -+ alpha = np.asarray(img.split()[-1]).astype(float) - - return gray, alpha diff --git a/pillow10.patch b/pillow10.patch new file mode 100644 index 0000000..86dec6a --- /dev/null +++ b/pillow10.patch @@ -0,0 +1,55 @@ +From db4296c12ca9c027eb9cd61b52195a78dfcc6711 Mon Sep 17 00:00:00 2001 +From: Theodore Ni <3806110+tjni@users.noreply.github.com> +Date: Sun, 27 Aug 2023 11:36:25 -0700 +Subject: [PATCH] Replace Image.ANTIALIAS with Image.LANCZOS + +This adds compatibility with Pillow 10, when ANTIALIAS was removed. +Meanwhile, LANCZOS has been an alias since Pillow 2.7.0. + +Co-authored-by: emilylange +--- + SSIM_CW-SSIM_comparison.ipynb | 8 ++++---- + ssim/ssimlib.py | 2 +- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/SSIM_CW-SSIM_comparison.ipynb b/SSIM_CW-SSIM_comparison.ipynb +index e713ffd..68ea8ce 100644 +--- a/SSIM_CW-SSIM_comparison.ipynb ++++ b/SSIM_CW-SSIM_comparison.ipynb +@@ -34,19 +34,19 @@ + "size = (256,256)\n", + "\n", + "im = Image.open('test-images/test3-orig.jpg')\n", +- "im = im.resize(size, Image.ANTIALIAS)\n", ++ "im = im.resize(size, Image.LANCZOS)\n", + "\n", + "# slightly rotated image\n", + "im_rot = Image.open('test-images/test3-rot.jpg')\n", +- "im_rot = im_rot.resize(size, Image.ANTIALIAS)\n", ++ "im_rot = im_rot.resize(size, Image.LANCZOS)\n", + "\n", + "# slightly modified lighting conditions\n", + "im_lig = Image.open('test-images/test3-lig.jpg')\n", +- "im_lig = im_lig.resize(size, Image.ANTIALIAS)\n", ++ "im_lig = im_lig.resize(size, Image.LANCZOS)\n", + "\n", + "# image cropped\n", + "im_cro = Image.open('test-images/test3-cro.jpg')\n", +- "im_cro = im_cro.resize(size, Image.ANTIALIAS)" ++ "im_cro = im_cro.resize(size, Image.LANCZOS)" + ] + }, + { +diff --git a/ssim/ssimlib.py b/ssim/ssimlib.py +index 693f951..b40a8d4 100644 +--- a/ssim/ssimlib.py ++++ b/ssim/ssimlib.py +@@ -45,7 +45,7 @@ def __init__(self, img, gaussian_kernel_1d=None, size=None): + # Resize image if size is defined and different + # from original image + if size and size != self.img.size: +- self.img = self.img.resize(size, Image.ANTIALIAS) ++ self.img = self.img.resize(size, Image.LANCZOS) + + # Set the size of the image + self.size = self.img.size diff --git a/pyssim-0.5.tar.gz b/pyssim-0.5.tar.gz deleted file mode 100644 index c5b314a..0000000 --- a/pyssim-0.5.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:438ff84a371f05e443f136ed6cba0afad4dd486038da39b6d0d9d189a80973a4 -size 2263693 diff --git a/pyssim-0.6.tar.gz b/pyssim-0.6.tar.gz new file mode 100644 index 0000000..9164be8 --- /dev/null +++ b/pyssim-0.6.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:813dfddd42db72c24a450ebc996f726ea2609115ec642d440be5501d5a4bff01 +size 2263609 diff --git a/python-pyssim.changes b/python-pyssim.changes index aafe6d5..c06f3a4 100644 --- a/python-pyssim.changes +++ b/python-pyssim.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Thu Oct 5 08:53:32 UTC 2023 - Markéta Machová + +- Update to 0.6 + * support numpy 1.20 +- Drop upstreamed numpy120.patch +- add upstream pillow10.patch + ------------------------------------------------------------------- Mon Mar 6 11:17:51 UTC 2023 - Daniel Garcia diff --git a/python-pyssim.spec b/python-pyssim.spec index 57761bf..95a255d 100644 --- a/python-pyssim.spec +++ b/python-pyssim.spec @@ -18,7 +18,7 @@ %global skip_python36 1 Name: python-pyssim -Version: 0.5 +Version: 0.6 Release: 0 Summary: Structured Similarity Image Metric (SSIM) License: MIT @@ -26,8 +26,8 @@ Group: Development/Languages/Python URL: https://github.com/jterrace/pyssim Source: https://files.pythonhosted.org/packages/source/p/pyssim/pyssim-%{version}.tar.gz Patch0: Pillow-imports.patch -# PATCH-FIX-UPSTREAM numpy120.patch gh#jterrace/pyssim#44 -Patch1: numpy120.patch +# PATCH-FIX-UPSTREAM https://github.com/jterrace/pyssim/commit/db4296c12ca9c027eb9cd61b52195a78dfcc6711 Replace Image.ANTIALIAS with Image.LANCZOS +Patch1: pillow10.patch BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros