From ef478ee883a606014ccd461ef837f76d6378ef06 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 20 Jun 2017 13:07:16 +0530 Subject: [PATCH] Maintain aspect ratio in thumbnail --- frappe/core/doctype/file/file.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/frappe/core/doctype/file/file.py b/frappe/core/doctype/file/file.py index f56ef12c32..324353c882 100755 --- a/frappe/core/doctype/file/file.py +++ b/frappe/core/doctype/file/file.py @@ -184,18 +184,15 @@ class File(NestedSet): except (requests.exceptions.HTTPError, requests.exceptions.SSLError, IOError): return - thumbnail = ImageOps.fit( - image, - (300, 300), - Image.ANTIALIAS - ) + size = 300, 300 + image.thumbnail(size) thumbnail_url = filename + "_small." + extn path = os.path.abspath(frappe.get_site_path("public", thumbnail_url.lstrip("/"))) try: - thumbnail.save(path) + image.save(path) self.db_set("thumbnail_url", thumbnail_url) except IOError: frappe.msgprint(_("Unable to write file format for {0}").format(path))