mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-10-21 16:27:15 +08:00
兼容pillow >=10 (#484)
This commit is contained in:
parent
ae96cb809a
commit
20faac3883
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user