有没有支持非预乘alpha的批量解包atlas工具,找遍github只有利用spine的命令行的,不支持非预乘alpha
from pathlib import Path
from typing import Literal
from SpineAtlas import ReadAtlasFile
def batch(fp: str = '', mode: Literal['Normal', 'Premul', 'NonPremul'] = 'Normal', scale: bool = True, subfolder: bool = True):
path = Path(fp) if fp else Path.cwd()
need = [i for i in (path.rglob('*.atlas') if subfolder else path.glob('*.atlas')) if i.is_file()]
for i in need:
try:
atlas = ReadAtlasFile(i)
except:
print(f'读取Atlas错误 --- {i.as_posix()}')
continue
if scale:
atlas.ReScale()
atlas.SaveFrames(i.parent.joinpath(i.stem), mode=mode)
if __name__ == '__main__':
path = r'' # atlas在pc上的路径
mode = 'Normal' # ['Normal', 'Premul', 'NonPremul'] Normal - 不做任何处理, Premul - 将贴图转换为预乘, NonPremul - 将贴图转换为非预乘
scale = True # 当贴图尺寸与atlas记录的贴图尺寸不符合时 重新计算帧的范围
subfolder = True # 是否查找子文件夹内的atlas
batch(path, mode, scale, subfolder)
试试这个库 https://pypi.org/project/SpineAtlas/