修复实时便签绘制图片报错’百分比必须在0-1之间'的问题

This commit is contained in:
云起 2023-02-27 15:08:36 +08:00
parent d73ec76dfc
commit 1589026b62

View File

@ -380,8 +380,12 @@ class PMImage:
:param transparent: 是否透明 :param transparent: 是否透明
""" """
if isinstance(percent, float): if isinstance(percent, float):
if percent < 0 or percent > 1: if percent < 0:
raise ValueError('百分比必须在0-1之间') percent = -percent
if percent > 10:
raise ValueError('图片传入百分比错误')
if percent > 1 and percent < 10:
percent /= 10
percent = [percent, 1 - percent] percent = [percent, 1 - percent]
if isinstance(colors, str): if isinstance(colors, str):
colors = [colors, '#FFFFFF'] colors = [colors, '#FFFFFF']