From 54a93a2f54e287d8464da6f965dac88c019615e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E7=92=83=E9=9B=A8=E8=90=BD?= <79274361+meng-luo@users.noreply.github.com> Date: Mon, 21 Oct 2024 23:49:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf(image=5Futils):=20=E5=9C=A8?= =?UTF-8?q?image=5Futils=E4=B8=AD=E7=A6=81=E7=94=A8=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=20(#1710)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🎈 perf(image_utils): 在image_utils中禁用代理下载 get_download_image_hash使用场景是访问腾讯服务器获取图片,无需走代理 * ✨ Add optional proxy support to image hash download function --- zhenxun/utils/image_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zhenxun/utils/image_utils.py b/zhenxun/utils/image_utils.py index eb245f48..ddcabd47 100644 --- a/zhenxun/utils/image_utils.py +++ b/zhenxun/utils/image_utils.py @@ -390,7 +390,7 @@ def get_img_hash(image_file: str | Path) -> str: return str(hash_value) -async def get_download_image_hash(url: str, mark: str) -> str: +async def get_download_image_hash(url: str, mark: str, use_proxy: bool = False) -> str: """下载图片获取哈希值 参数: @@ -402,7 +402,7 @@ async def get_download_image_hash(url: str, mark: str) -> str: """ try: if await AsyncHttpx.download_file( - url, TEMP_PATH / f"compare_download_{mark}_img.jpg" + 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") return str(img_hash)