From 801ece12dd4f4b374db69748e258d92160938bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wuyi=E6=97=A0=E7=96=91?= <444835641@qq.com> Date: Mon, 17 Jul 2023 02:51:47 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E8=AF=B7?= =?UTF-8?q?=E6=B1=82BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gsuid_core/utils/api/ambr/request.py | 4 ++-- gsuid_core/utils/image/convert.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gsuid_core/utils/api/ambr/request.py b/gsuid_core/utils/api/ambr/request.py index 6bd1330..6991437 100644 --- a/gsuid_core/utils/api/ambr/request.py +++ b/gsuid_core/utils/api/ambr/request.py @@ -121,8 +121,8 @@ async def get_ambr_icon(type: str, icon_name: str, path: Path) -> Image.Image: file_path = path / f'{icon_name}.png' if file_path.exists(): - async with aiofiles.open(path, 'rb') as f: - return Image.open(await f.read()) + async with aiofiles.open(file_path, 'rb') as f: + return Image.open(BytesIO(await f.read())) async with AsyncClient(timeout=None) as client: req = await client.get( diff --git a/gsuid_core/utils/image/convert.py b/gsuid_core/utils/image/convert.py index a075433..c70022a 100644 --- a/gsuid_core/utils/image/convert.py +++ b/gsuid_core/utils/image/convert.py @@ -45,7 +45,7 @@ async def convert_img( if isinstance(img, Image.Image): img = img.convert('RGB') result_buffer = BytesIO() - img.save(result_buffer, format='PNG', quality=80, subsampling=0) + img.save(result_buffer, format='JPEG', quality=85) res = result_buffer.getvalue() if is_base64: res = 'base64://' + b64encode(res).decode()