48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Export background / highlight from the PSD design (UEFI x64 main)."""
|
|
import os
|
|
from psd_tools import PSDImage
|
|
|
|
SRC = '/path/to/pf/PSD/UEFI/x64/main/main.psd'
|
|
OUT = '/path/to/pf/ParavisGrub/theme/main'
|
|
os.makedirs(OUT, exist_ok=True)
|
|
|
|
KEEP_TEXT = {'Главное Меню', 'Дополнительное Меню', '© Paravis.RU', 'Paravis Flash'}
|
|
|
|
|
|
def hide_item_text(layer):
|
|
"""Hide menu-item text layers, keep headers/decoration."""
|
|
for ch in layer:
|
|
if ch.kind == 'type' and (ch.name or '') not in KEEP_TEXT:
|
|
ch.visible = False
|
|
elif ch.kind == 'group':
|
|
hide_item_text(ch)
|
|
|
|
|
|
psd = PSDImage.open(SRC)
|
|
for layer in psd:
|
|
nm = layer.name or ''
|
|
if nm.startswith('ТЕКСТ_БЕЗ_ОБВОДКИ'):
|
|
for ch in layer:
|
|
ch.visible = False
|
|
elif nm.startswith('ТЕКСТ_С_ОБВОДКОЙ'):
|
|
hide_item_text(layer)
|
|
|
|
img = psd.composite()
|
|
img.save(os.path.join(OUT, 'background.png'))
|
|
print('background.png', img.size)
|
|
|
|
# --- highlight bar: take F2 (item 1) from the hidden "ВЫДЕЛЕНЫЕ_ПУНКТЫ" group
|
|
psd2 = PSDImage.open(SRC)
|
|
sel = None
|
|
for layer in psd2.descendants():
|
|
if (layer.name or '').strip() in ('F2', 'F3') and layer.kind == 'pixel':
|
|
if layer.name.strip() == 'F2':
|
|
sel = layer
|
|
if sel is None:
|
|
print('highlight layer not found')
|
|
else:
|
|
bar = sel.topil()
|
|
bar.save(os.path.join(OUT, 'sel_bar.png'))
|
|
print('sel_bar.png', bar.size, 'bbox', sel.bbox)
|