From be2747e4d4b820ca0f1f988d3b77a628da26fe7b Mon Sep 17 00:00:00 2001 From: Kyomotoi Date: Thu, 8 Jul 2021 22:09:00 +0800 Subject: =?UTF-8?q?=F0=9F=94=96=E2=99=BB=EF=B8=8F=F0=9F=90=9B=F0=9F=94=A7?= =?UTF-8?q?=F0=9F=94=A5=F0=9F=93=9D=20=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=EF=BC=9AYHN-001-A03?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔖 更新版本至:YHN-001-A03 ✨ 新增插件: - 涩图 - 闲聊(文爱 ♻️ 重构: - Service - 所有插件 🐛 修复部分小bug 🔧 暂时移除部分设置 🔥 删除: - 插件:nsfw、wife。日后加回 - 插件 essential 中部分内容 📝 更新README --- ATRI/utils/img.py | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 ATRI/utils/img.py (limited to 'ATRI/utils/img.py') diff --git a/ATRI/utils/img.py b/ATRI/utils/img.py deleted file mode 100644 index 147af79..0000000 --- a/ATRI/utils/img.py +++ /dev/null @@ -1,23 +0,0 @@ -import os -from PIL import Image, ImageFile - -from ATRI.exceptions import WriteError - - -def compress_image(out_file, kb=300, quality=85, k=0.9) -> str: - """将目标图片进行压缩""" - o_size = os.path.getsize(out_file) // 1024 - if o_size <= kb: - return out_file - - ImageFile.LOAD_TRUNCATED_IMAGES = True # type: ignore - while o_size > kb: - img = Image.open(out_file) - x, y = img.size - out = img.resize((int(x * k), int(y * k)), Image.ANTIALIAS) - try: - out.save(out_file, quality=quality) - except WriteError: - raise WriteError("Writing file failed!") - o_size = os.path.getsize(out_file) // 1024 - return out_file -- cgit v1.2.3