瀏覽代碼

Maintain aspect ratio in thumbnail

version-14
Faris Ansari 8 年之前
父節點
當前提交
ef478ee883
共有 1 個文件被更改,包括 3 次插入6 次删除
  1. +3
    -6
      frappe/core/doctype/file/file.py

+ 3
- 6
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))


Loading…
取消
儲存