From 617a961816c947e7818359d3bda9acfb52678a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Sun, 22 Dec 2024 18:14:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E5=9B=BE=E5=83=8F?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaomusic/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/xiaomusic/utils.py b/xiaomusic/utils.py index d6bfb030b5..6d0a06a901 100644 --- a/xiaomusic/utils.py +++ b/xiaomusic/utils.py @@ -643,14 +643,19 @@ def _save_picture(picture_data, save_root, file_path): try: _resize_save_image(picture_data, picture_path) except Exception as e: - log.exception(f"Error _resize_save_image: {e}") + log.warning(f"Error _resize_save_image: {e}") return picture_path def _resize_save_image(image_bytes, save_path, max_size=300): # 将 bytes 转换为 PIL Image 对象 - image = Image.open(io.BytesIO(image_bytes)) - image = image.convert("RGB") + image = None + try: + image = Image.open(io.BytesIO(image_bytes)) + image = image.convert("RGB") + except Exception as e: + log.warning(f"Error _resize_save_image: {e}") + return # 获取原始尺寸 original_width, original_height = image.size