From fc422f4a97bd12ceadb05ffbad582e2a921c44f3 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 2 Jun 2022 13:03:57 +0530 Subject: [PATCH] chore(deps): Bump Pillow from 9.0.1 to 9.1.1 Includes security fixes, API & constants deprecations Changelog: https://pillow.readthedocs.io/en/stable/releasenotes/index.html --- frappe/core/doctype/file/file.py | 4 ++-- frappe/utils/data.py | 2 +- frappe/utils/image.py | 6 ++---- requirements.txt | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/frappe/core/doctype/file/file.py b/frappe/core/doctype/file/file.py index 1bcbaf161a..e8b8da76ab 100755 --- a/frappe/core/doctype/file/file.py +++ b/frappe/core/doctype/file/file.py @@ -341,9 +341,9 @@ class File(Document): size = width, height if crop: - image = ImageOps.fit(image, size, Image.ANTIALIAS) + image = ImageOps.fit(image, size, Image.Resampling.LANCZOS) else: - image.thumbnail(size, Image.ANTIALIAS) + image.thumbnail(size, Image.Resampling.LANCZOS) thumbnail_url = f"{filename}_{suffix}.{extn}" path = os.path.abspath(frappe.get_site_path("public", thumbnail_url.lstrip("/"))) diff --git a/frappe/utils/data.py b/frappe/utils/data.py index 60770ef6a9..49f9ead437 100644 --- a/frappe/utils/data.py +++ b/frappe/utils/data.py @@ -1349,7 +1349,7 @@ def get_thumbnail_base64_for_image(src): original_size = image.size size = 50, 50 - image.thumbnail(size, Image.ANTIALIAS) + image.thumbnail(size, Image.Resampling.LANCZOS) base64_string = image_to_base64(image, extn) return { diff --git a/frappe/utils/image.py b/frappe/utils/image.py index 0cbc02fb31..8823ea3dfe 100644 --- a/frappe/utils/image.py +++ b/frappe/utils/image.py @@ -7,8 +7,6 @@ from PIL import Image def resize_images(path, maxdim=700): - from PIL import Image - size = (maxdim, maxdim) for basepath, folders, files in os.walk(path): for fname in files: @@ -16,7 +14,7 @@ def resize_images(path, maxdim=700): if extn in ("jpg", "jpeg", "png", "gif"): im = Image.open(os.path.join(basepath, fname)) if im.size[0] > size[0] or im.size[1] > size[1]: - im.thumbnail(size, Image.ANTIALIAS) + im.thumbnail(size, Image.Resampling.LANCZOS) im.save(os.path.join(basepath, fname)) print("resized {0}".format(os.path.join(basepath, fname))) @@ -56,7 +54,7 @@ def optimize_image( image = Image.open(io.BytesIO(content)) image_format = content_type.split("/")[1] size = max_width, max_height - image.thumbnail(size, Image.LANCZOS) + image.thumbnail(size, Image.Resampling.LANCZOS) output = io.BytesIO() image.save( diff --git a/requirements.txt b/requirements.txt index 66a75c99ca..1a6b6120a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -33,7 +33,7 @@ parse~=1.19.0 passlib~=1.7.4 paytmchecksum~=1.7.0 pdfkit~=1.0.0 -Pillow~=9.0.0 +Pillow~=9.1.1 premailer~=3.8.0 psutil~=5.9.1 psycopg2-binary~=2.9.1