From 1589026b62355ac599692df4f1f62cc7f314a302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E8=B5=B7?= Date: Mon, 27 Feb 2023 15:08:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=9E=E6=97=B6=E4=BE=BF?= =?UTF-8?q?=E7=AD=BE=E7=BB=98=E5=88=B6=E5=9B=BE=E7=89=87=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E2=80=99=E7=99=BE=E5=88=86=E6=AF=94=E5=BF=85=E9=A1=BB=E5=9C=A8?= =?UTF-8?q?0-1=E4=B9=8B=E9=97=B4'=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LittlePaimon/utils/image.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/LittlePaimon/utils/image.py b/LittlePaimon/utils/image.py index fd33d15..32a3ced 100644 --- a/LittlePaimon/utils/image.py +++ b/LittlePaimon/utils/image.py @@ -380,8 +380,12 @@ class PMImage: :param transparent: 是否透明 """ if isinstance(percent, float): - if percent < 0 or percent > 1: - raise ValueError('百分比必须在0-1之间') + if percent < 0: + percent = -percent + if percent > 10: + raise ValueError('图片传入百分比错误') + if percent > 1 and percent < 10: + percent /= 10 percent = [percent, 1 - percent] if isinstance(colors, str): colors = [colors, '#FFFFFF']