diff options
author | Kyomotoi <[email protected]> | 2021-05-04 14:27:56 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2021-05-04 14:27:56 +0800 |
commit | ea7f48011c34fdaec7e91af7eb373c8174e439e6 (patch) | |
tree | e4f14eaacde37774d49e7f98ac1ff4635049d80a /ATRI/utils/img.py | |
parent | 07a7e41f72cfa9dfd207a04445f4aa5b0b6fa3ce (diff) | |
download | ATRI-ea7f48011c34fdaec7e91af7eb373c8174e439e6.tar.gz ATRI-ea7f48011c34fdaec7e91af7eb373c8174e439e6.tar.bz2 ATRI-ea7f48011c34fdaec7e91af7eb373c8174e439e6.zip |
✨🐛 更新
新增:老婆!
新增:涩图
修复:manage中出现的bug
优化:nsfw不再用float,换为int
Diffstat (limited to 'ATRI/utils/img.py')
-rw-r--r-- | ATRI/utils/img.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/ATRI/utils/img.py b/ATRI/utils/img.py index f96f368..b227b3d 100644 --- a/ATRI/utils/img.py +++ b/ATRI/utils/img.py @@ -4,12 +4,12 @@ from PIL import Image, ImageFile from ATRI.exceptions import WriteError -def compress_image(out_file, kb=500, quality=85, k=0.9) -> str: +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) @@ -18,6 +18,6 @@ def compress_image(out_file, kb=500, quality=85, k=0.9) -> str: try: out.save(out_file, quality=quality) except WriteError: - raise WriteError("Writing file failed!") + raise WriteError('Writing file failed!') o_size = os.path.getsize(out_file) // 1024 return out_file |