From cc9a866142d620b0cd80fd3ca6f5e70d1fb64fcf Mon Sep 17 00:00:00 2001 From: Hussain Nagaria Date: Mon, 18 Dec 2023 22:00:44 +0530 Subject: [PATCH] docs: get_thumbnail_base64_for_image --- frappe/utils/data.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frappe/utils/data.py b/frappe/utils/data.py index c5eda50136..1feaeab0aa 100644 --- a/frappe/utils/data.py +++ b/frappe/utils/data.py @@ -1563,7 +1563,17 @@ def is_image(filepath: str) -> bool: return (guess_type(filepath)[0] or "").startswith("image/") -def get_thumbnail_base64_for_image(src): +def get_thumbnail_base64_for_image(src: str) -> dict[str, str] | None: + """Return the base64 encoded string for the thumbnail of the given image source path. + + Example return value: + + { + "base64": "data:image/ext;base64,...", + "width": 50, + "height": 50 + } + """ from os.path import exists as file_exists from PIL import Image