mirror of
https://github.com/hanxi/xiaomusic.git
synced 2025-12-06 14:52:50 +08:00
fix: 处理图像报错
This commit is contained in:
@@ -643,14 +643,19 @@ def _save_picture(picture_data, save_root, file_path):
|
|||||||
try:
|
try:
|
||||||
_resize_save_image(picture_data, picture_path)
|
_resize_save_image(picture_data, picture_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.exception(f"Error _resize_save_image: {e}")
|
log.warning(f"Error _resize_save_image: {e}")
|
||||||
return picture_path
|
return picture_path
|
||||||
|
|
||||||
|
|
||||||
def _resize_save_image(image_bytes, save_path, max_size=300):
|
def _resize_save_image(image_bytes, save_path, max_size=300):
|
||||||
# 将 bytes 转换为 PIL Image 对象
|
# 将 bytes 转换为 PIL Image 对象
|
||||||
image = Image.open(io.BytesIO(image_bytes))
|
image = None
|
||||||
image = image.convert("RGB")
|
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
|
original_width, original_height = image.size
|
||||||
|
|||||||
Reference in New Issue
Block a user