From 20faac3883434501783a6ac98e5ffc0f92d1aa19 Mon Sep 17 00:00:00 2001 From: Cathgao <21031564+Cathgao@users.noreply.github.com> Date: Mon, 6 Nov 2023 16:27:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9pillow=20>=3D10=20(#484)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LittlePaimon/plugins/Paimon_Wiki/draw_map.py | 6 +++--- LittlePaimon/utils/image.py | 6 +++--- LittlePaimon/utils/message.py | 4 ++-- LittlePaimon/utils/requests.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/LittlePaimon/plugins/Paimon_Wiki/draw_map.py b/LittlePaimon/plugins/Paimon_Wiki/draw_map.py index 5fde306..5eb6411 100644 --- a/LittlePaimon/plugins/Paimon_Wiki/draw_map.py +++ b/LittlePaimon/plugins/Paimon_Wiki/draw_map.py @@ -92,9 +92,9 @@ async def draw_map(name: str, map_: str): map_img.paste(point_icon, (point_trans[0] - 16, point_trans[1] - 16), point_icon) scale_f = map_img.width / map_img.height if scale_f > 980 / 850: - map_img = map_img.resize((math.ceil(850 * scale_f), 850), Image.ANTIALIAS) + map_img = map_img.resize((math.ceil(850 * scale_f), 850), Image.LANCZOS) else: - map_img = map_img.resize((980, math.ceil(980 / scale_f)), Image.ANTIALIAS) + map_img = map_img.resize((980, math.ceil(980 / scale_f)), Image.LANCZOS) map_img = map_img.crop((0, 0, 980, 850)) map_img = ImageOps.expand(map_img, border=4, fill='#633da3') total_img = PMImage(await load_image(RESOURCE_BASE_PATH / 'genshin_map' / 'bg.png')) @@ -150,7 +150,7 @@ async def get_full_map(names: List[str], map_: str): for i, points in enumerate(resources_points): resource_icon = box_icon.copy() resource_icon.alpha_composite(await aiorequests.get_img(resources[i].icon, size=(90, 90)), (28, 15)) - resource_icon = resource_icon.resize((48, 48), Image.ANTIALIAS) + resource_icon = resource_icon.resize((48, 48), Image.LANCZOS) if len(points) >= 3: group_point = img.k_means_points(points, 2000) else: diff --git a/LittlePaimon/utils/image.py b/LittlePaimon/utils/image.py index ce05776..937d781 100644 --- a/LittlePaimon/utils/image.py +++ b/LittlePaimon/utils/image.py @@ -194,7 +194,7 @@ class PMImage: height = height[0] self.draw.text((width, height), text, color, font) elif align in ['center', 'right']: - w, h = self.draw.textsize(text, font) + _, _, w, h = self.draw.textbbox((0, 0), text, font) if align == 'center': w = width[0] + (width[1] - width[0] - w) / 2 if isinstance(width, tuple) else width h = height[0] + (height[1] - height[0] - h) / 2 if isinstance(height, tuple) else height @@ -574,9 +574,9 @@ async def load_image( img = img.convert(mode) if size: if isinstance(size, float): - img = img.resize((int(img.size[0] * size), int(img.size[1] * size)), Image.ANTIALIAS) + img = img.resize((int(img.size[0] * size), int(img.size[1] * size)), Image.LANCZOS) elif isinstance(size, tuple): - img = img.resize(size, Image.ANTIALIAS) + img = img.resize(size, Image.LANCZOS) if crop: img = img.crop(crop) return img diff --git a/LittlePaimon/utils/message.py b/LittlePaimon/utils/message.py index cdffee6..3fbf6df 100644 --- a/LittlePaimon/utils/message.py +++ b/LittlePaimon/utils/message.py @@ -51,9 +51,9 @@ class MessageBuild: img = img.image if size: if isinstance(size, float): - img = img.resize((int(img.size[0] * size), int(img.size[1] * size)), Image.ANTIALIAS) + img = img.resize((int(img.size[0] * size), int(img.size[1] * size)), Image.LANCZOS) elif isinstance(size, tuple): - img = img.resize(size, Image.ANTIALIAS) + img = img.resize(size, Image.LANCZOS) if crop: img = img.crop(crop) if mode: diff --git a/LittlePaimon/utils/requests.py b/LittlePaimon/utils/requests.py index 69bf96f..0f191d1 100644 --- a/LittlePaimon/utils/requests.py +++ b/LittlePaimon/utils/requests.py @@ -125,9 +125,9 @@ class aiorequests: img = Image.open(BytesIO(resp)) if size: if isinstance(size, float): - img = img.resize((int(img.size[0] * size), int(img.size[1] * size)), Image.ANTIALIAS) + img = img.resize((int(img.size[0] * size), int(img.size[1] * size)), Image.LANCZOS) elif isinstance(size, tuple): - img = img.resize(size, Image.ANTIALIAS) + img = img.resize(size, Image.LANCZOS) if mode: img = img.convert(mode) if crop: