Repository: internetarchive/openlibrary

Issue:
Image.ANTIALIAS is deprecated and will be removed in Pillow 10 (2023-07-01)
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

When we run our pytests, we get this warning.
```
openlibrary/coverstore/tests/test_coverstore.py: 13 warnings
  /home/runner/work/openlibrary/openlibrary/openlibrary/coverstore/coverlib.py:105:
    DeprecationWarning: ANTIALIAS is deprecated and will be removed in Pillow 10 (2023-07-01).
      Use LANCZOS or Resampling.LANCZOS instead.
        return image.resize(size, Image.ANTIALIAS)
```
Our code currently uses `Image.ANTIALIAS` here:
* https://github.com/search?q=repo%3Ainternetarchive%2Fopenlibrary+.ANTIALIAS
### Describe the problem that you'd like solved
<!-- A clear and concise description of what you want to happen. -->
1. Please modify these instances to use `LANCZOS` or `Resampling.LANCZOS` instead.
* https://pillow.readthedocs.io/en/stable/releasenotes/2.7.0.html#antialias-renamed-to-lanczos
* https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.LANCZOS
* https://pillow.readthedocs.io/en/stable/reference/Image.html#resampling-filters
2. Provide tests to ensure that image quality is the same (or better) when all modified code is run.

### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

<!-- Which suggestions or requirements should be considered for how feature needs to appear or be implemented? -->

### Additional context
<!-- Add any other context or screenshots about the feature request here. -->

### Stakeholders
<!-- @ tag stakeholders of this bug -->





Discussion:
Hi, I will work on this.

@cclauss Regarding Tests, could you please clarify. Would you like image comparisons of before and after or would it be some sort of test on pytest? 

Thank you for your assistance,

Debbie




I think before and after screenshots pasted into the pull request should be sufficient.

Resolving patch:
diff --git a/openlibrary/coverstore/code.py b/openlibrary/coverstore/code.py
--- a/openlibrary/coverstore/code.py
+++ b/openlibrary/coverstore/code.py
@@ -545,7 +545,7 @@ def render_list_preview_image(lst_key):
             basewidth = 162
             wpercent = basewidth / float(img.size[0])
             hsize = int(float(img.size[1]) * float(wpercent))
-            img = img.resize((basewidth, hsize), Image.ANTIALIAS)
+            img = img.resize((basewidth, hsize), Image.LANCZOS)
             image.append(img)
     max_height = 0
     for img in image:
@@ -576,7 +576,7 @@ def render_list_preview_image(lst_key):
     else:
         background.paste(image[0], (431, 174 + max_height - image[0].size[1]))
 
-    logo = logo.resize((120, 74), Image.ANTIALIAS)
+    logo = logo.resize((120, 74), Image.LANCZOS)
     background.paste(logo, (880, 14), logo)
 
     draw = ImageDraw.Draw(background)
diff --git a/openlibrary/coverstore/coverlib.py b/openlibrary/coverstore/coverlib.py
--- a/openlibrary/coverstore/coverlib.py
+++ b/openlibrary/coverstore/coverlib.py
@@ -102,7 +102,7 @@ def resize_image(image, size):
         y = size[1]
     size = x, y
 
-    return image.resize(size, Image.ANTIALIAS)
+    return image.resize(size, Image.LANCZOS)
 
 
 def find_image_path(filename):


Test patch: