59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
"""
|
|
创建活动状态图标
|
|
"""
|
|
from PIL import Image, ImageEnhance
|
|
import os
|
|
|
|
def create_active_icon(input_path, output_path):
|
|
"""
|
|
基于现有图标创建一个活动状态的图标
|
|
活动状态图标将更亮、更鲜艳
|
|
"""
|
|
try:
|
|
# 打开原始图标
|
|
img = Image.open(input_path)
|
|
|
|
# 增加亮度
|
|
enhancer = ImageEnhance.Brightness(img)
|
|
brightened_img = enhancer.enhance(1.3) # 增加30%亮度
|
|
|
|
# 增加对比度
|
|
enhancer = ImageEnhance.Contrast(brightened_img)
|
|
contrasted_img = enhancer.enhance(1.2) # 增加20%对比度
|
|
|
|
# 增加颜色饱和度
|
|
enhancer = ImageEnhance.Color(contrasted_img)
|
|
colored_img = enhancer.enhance(1.5) # 增加50%饱和度
|
|
|
|
# 保存活动状态图标
|
|
colored_img.save(output_path)
|
|
print(f"活动状态图标已创建: {output_path}")
|
|
return True
|
|
except Exception as e:
|
|
print(f"创建活动状态图标失败: {e}")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
# 确定图标路径
|
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
resources_dir = os.path.join(script_dir, "resources")
|
|
|
|
# 确保资源目录存在
|
|
if not os.path.exists(resources_dir):
|
|
os.makedirs(resources_dir)
|
|
print(f"创建资源目录: {resources_dir}")
|
|
|
|
# 图标路径
|
|
icon_path = os.path.join(resources_dir, "icon.png")
|
|
active_icon_path = os.path.join(resources_dir, "icon_active.png")
|
|
|
|
# 检查原始图标是否存在
|
|
if not os.path.exists(icon_path):
|
|
print(f"错误: 原始图标不存在: {icon_path}")
|
|
else:
|
|
# 创建活动状态图标
|
|
if create_active_icon(icon_path, active_icon_path):
|
|
print("成功创建活动状态图标")
|
|
else:
|
|
print("创建活动状态图标失败")
|