From 0bd1d6c59ce0754e7fc1eb95bc4f994785850773 Mon Sep 17 00:00:00 2001 From: webjoin111 <455457521@qq.com> Date: Mon, 10 Nov 2025 21:05:26 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20perf(image=5Futils):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87=E5=93=88=E5=B8=8C=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=81=BF=E5=85=8D=E9=98=BB=E5=A1=9E=E5=BC=82=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhenxun/utils/image_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zhenxun/utils/image_utils.py b/zhenxun/utils/image_utils.py index d5affc7d..8ad9f01e 100644 --- a/zhenxun/utils/image_utils.py +++ b/zhenxun/utils/image_utils.py @@ -6,7 +6,7 @@ import random import re import imagehash -from nonebot.utils import is_coroutine_callable +from nonebot.utils import is_coroutine_callable, run_sync from PIL import Image from zhenxun.configs.path_config import TEMP_PATH @@ -378,7 +378,9 @@ async def get_download_image_hash(url: str, mark: str, use_proxy: bool = False) if await AsyncHttpx.download_file( url, TEMP_PATH / f"compare_download_{mark}_img.jpg", use_proxy=use_proxy ): - img_hash = get_img_hash(TEMP_PATH / f"compare_download_{mark}_img.jpg") + img_hash = await run_sync(get_img_hash)( + TEMP_PATH / f"compare_download_{mark}_img.jpg" + ) return str(img_hash) except Exception as e: logger.warning("下载读取图片Hash出错", e=e)