mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
🚨 移除无用导入
This commit is contained in:
parent
c5aa0d5351
commit
6c80bb6629
2
bot.py
2
bot.py
@ -14,7 +14,7 @@ driver.register_adapter(KaiheilaAdapter)
|
||||
driver.register_adapter(DoDoAdapter)
|
||||
# driver.register_adapter(DiscordAdapter)
|
||||
|
||||
from zhenxun.services.db_context import init, disconnect
|
||||
from zhenxun.services.db_context import disconnect, init
|
||||
|
||||
driver.on_startup(init)
|
||||
driver.on_shutdown(disconnect)
|
||||
|
||||
@ -5,12 +5,11 @@ from pathlib import Path
|
||||
import random
|
||||
import re
|
||||
|
||||
import cv2
|
||||
import imagehash
|
||||
from nonebot.utils import is_coroutine_callable
|
||||
from PIL import Image
|
||||
|
||||
from zhenxun.configs.path_config import IMAGE_PATH, TEMP_PATH
|
||||
from zhenxun.configs.path_config import TEMP_PATH
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.http_utils import AsyncHttpx
|
||||
|
||||
@ -347,30 +346,6 @@ async def build_sort_image(
|
||||
return A
|
||||
|
||||
|
||||
def compressed_image(
|
||||
in_file: str | Path,
|
||||
out_file: str | Path | None = None,
|
||||
ratio: float = 0.9,
|
||||
):
|
||||
"""压缩图片
|
||||
|
||||
参数:
|
||||
in_file: 被压缩的文件路径
|
||||
out_file: 压缩后输出的文件路径
|
||||
ratio: 压缩率,宽高 * 压缩率
|
||||
"""
|
||||
in_file = IMAGE_PATH / in_file if isinstance(in_file, str) else in_file
|
||||
if out_file:
|
||||
out_file = IMAGE_PATH / out_file if isinstance(out_file, str) else out_file
|
||||
else:
|
||||
out_file = in_file
|
||||
h, w, d = cv2.imread(str(in_file.absolute())).shape
|
||||
img = cv2.resize(
|
||||
cv2.imread(str(in_file.absolute())), (int(w * ratio), int(h * ratio))
|
||||
)
|
||||
cv2.imwrite(str(out_file.absolute()), img)
|
||||
|
||||
|
||||
def get_img_hash(image_file: str | Path) -> str:
|
||||
"""获取图片的hash值
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user