预览,录屏的闪烁是本地渲染一次性加载太多的问题,非图标本身闪烁
下面的python脚本直接输出(输出了webp缩略图)
import os
from PIL import Image
from pathlib import Path
source_dir = "1000多套图标"
output_dir = "webp输出"
os.makedirs(output_dir, exist_ok=True)
for season in os.listdir(source_dir):
season_path = os.path.join(source_dir, season)
if not os.path.isdir(season_path):
continue
for icon_set in os.listdir(season_path):
icon_set_path = os.path.join(season_path, icon_set)
if not os.path.isdir(icon_set_path):
continue
images = []
png_files = sorted([f for f in os.listdir(icon_set_path) if f.endswith('.png')])
if not png_files:
continue
# 先找出所有图片裁剪后的最大尺寸
max_width = 0
max_height = 0
temp_images = []
for png_file in png_files:
img_path = os.path.join(icon_set_path, png_file)
img = Image.open(img_path).convert('RGBA')
# 自动裁剪透明边缘
bbox = img.getbbox()
if bbox:
img = img.crop(bbox)
temp_images.append(img)
max_width = max(max_width, img.width)
max_height = max(max_height, img.height)
# 创建正方形画布并居中放置
max_side = max(max_width, max_height)
for img in temp_images:
canvas = Image.new('RGBA', (max_side, max_side), (0, 0, 0, 0))
x = (max_side - img.width) // 2
y = (max_side - img.height) // 2
canvas.paste(img, (x, y), img)
images.append(canvas)
if images:
output_filename = f"{season}_{icon_set}.webp"
output_path = os.path.join(output_dir, output_filename)
images[0].save(
output_path,
save_all=True,
append_images=images[1:],
duration=100,
loop=0,
lossless=True
)
print(f"已生成: {output_filename}")
print(f"\n转换完成!所有WebP已保存到 {output_dir} 文件夹")
© 版权声明
NOTICE
1400471815@qq.com
|
Copyright © 2023~2026
01
DISCLAIMER
1.本站提供的一切软件、教程和内容信息仅限用于学习和研究目的。
2.不得私自将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
3.本站资源来自网络收集整理,版权争议与本站无关。您必须在下载后的24个小时之内,从您的设备中彻底删除上述内容。
4.如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。
5.我们非常重视版权问题,如有侵权请联系站长永久性从本站删除 QQ:1400471815,敬请谅解!
02
VIP PRIVILEGE
遇到付费内容?升级终身VIP即可全站免费畅享所有资源,可以联系我的微信进行开通。
少点烦恼聊天 QQ 5群:1128711394
THE END

