feat: 初始化画个标仓库 - AI驱动设计系统(BYOK模式) - 224源/371504图标+25海报源+130技能
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
# 生成甄房 logo 位图替换资源
|
||||
# 关键:旧 logo 的墨迹占画布约 90%,而甄房 mark 只占 69% —— 直接替换会让 logo 视觉缩小 25%。
|
||||
# 本脚本把 mark 的墨迹等比缩放到占画布 90%,保持与原资源等大,替换后不改变版式。
|
||||
# 用法: python _design-test/build-logos.py (预演)
|
||||
# python _design-test/build-logos.py --write (真写)
|
||||
import os, sys, shutil
|
||||
from PIL import Image
|
||||
|
||||
SRC = r'D:\SGP_KF\DrawLogo\_design-test\logo\png'
|
||||
ZF = r'e:\KF_7\ZhenOS-ZF'
|
||||
WRITE = '--write' in sys.argv
|
||||
INK_RATIO = 0.90 # 墨迹占画布比例,与原资源对齐
|
||||
|
||||
|
||||
def fitted(src_name, canvas, ratio=INK_RATIO):
|
||||
"""把 src 的墨迹等比缩放到占 canvas 的 ratio,居中放到透明画布上"""
|
||||
im = Image.open(os.path.join(SRC, src_name)).convert('RGBA')
|
||||
bb = im.getchannel('A').getbbox()
|
||||
ink = im.crop(bb)
|
||||
k = (canvas * ratio) / max(ink.width, ink.height)
|
||||
ink = ink.resize((max(1, round(ink.width * k)), max(1, round(ink.height * k))), Image.LANCZOS)
|
||||
out = Image.new('RGBA', (canvas, canvas), (0, 0, 0, 0))
|
||||
out.paste(ink, ((canvas - ink.width) // 2, (canvas - ink.height) // 2), ink)
|
||||
return out
|
||||
|
||||
|
||||
JOBS = [
|
||||
# 目标路径, 生成方式, 说明
|
||||
(f'{ZF}/ruoyi-ui/src/assets/logo/logo.png', ('fitted', 'mark-p80-ink.png', 1000), 'WEB 登录页/工具页 · 墨蓝标'),
|
||||
(f'{ZF}/ruoyi-ui/src/assets/logo/logo-sidebar.png', ('fitted', 'mark-p80-white.png', 1000), 'WEB 侧栏(墨蓝底)· 白标'),
|
||||
(f'{ZF}/zhenfang-uni/src/static/logo.png', ('fitted', 'mark-p80-ink.png', 1000), 'H5 登录页(白卡内)· 墨蓝标'),
|
||||
(f'{ZF}/ruoyi-ui/public/favicon.png', ('plain', 'appicon-512.png', None), 'WEB favicon · 应用图标'),
|
||||
(f'{ZF}/xiaohuju/build/icons/icon.png', ('plain', 'appicon-512.png', None), 'Electron 托盘/窗口图标'),
|
||||
]
|
||||
|
||||
ICO_OUT = f'{ZF}/xiaohuju/build/icons/icon.ico'
|
||||
|
||||
for dest, spec, label in JOBS:
|
||||
before = os.path.getsize(dest) if os.path.exists(dest) else 0
|
||||
kind = spec[0]
|
||||
img = fitted(spec[1], spec[2]) if kind == 'fitted' else Image.open(os.path.join(SRC, spec[1])).convert('RGBA')
|
||||
print(' %-58s %sx%s (%dB -> ~)' % (label, img.width, img.height, before))
|
||||
if WRITE:
|
||||
img.save(dest)
|
||||
|
||||
# 多尺寸 ICO(含 256,Windows 图标规范)
|
||||
ico_sizes = [16, 24, 32, 48, 64, 128, 256]
|
||||
base = Image.open(os.path.join(SRC, 'appicon-1024.png')).convert('RGBA')
|
||||
imgs = [base.resize((s, s), Image.LANCZOS) for s in ico_sizes]
|
||||
print(' %-58s %s' % ('Electron 应用图标 ICO', '/'.join(str(s) for s in ico_sizes)))
|
||||
if WRITE:
|
||||
imgs[-1].save(ICO_OUT, format='ICO', sizes=[(s, s) for s in ico_sizes])
|
||||
|
||||
print('\n' + ('已写入' if WRITE else '预演,未写入(加 --write 生效)'))
|
||||
print('注:xiaohuju/build/icons/icon.icns(macOS)需在 macOS 上用 iconutil 生成,本机跳过;')
|
||||
print(' xiaohuju/resources/app.png 是启动背景稿(含蓝色主体图形),需设计重做,本脚本不动。')
|
||||
Reference in New Issue
Block a user