forked from drewcassidy/KSP-Toolkit
32 lines
1.1 KiB
Python
Executable File
32 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
import os
|
|
import os.path
|
|
import argparse
|
|
import dds
|
|
|
|
parser = argparse.ArgumentParser(description="Checks any number of dds files for common issues, including formats not supported by KSP, and DXT5 textures that don't use the alpha channel.")
|
|
parser.add_argument('files', type=str, nargs='*', help = "input dds files")
|
|
parser.add_argument('--convertcmd', type=str, metavar='CMD', default="convert", help="name of imagemagick's convert tool (default: %(default)s)")
|
|
parser.add_argument('--infocmd', type=str, metavar='CMD', default="nvddsinfo", help="name of the nvidia dds info tool (default: %(default)s)")
|
|
|
|
args = parser.parse_args()
|
|
|
|
dds.convertcmd = args.convertcmd
|
|
dds.infocmd = args.infocmd
|
|
|
|
for argv in args.files:
|
|
file = os.path.abspath(argv)
|
|
|
|
info = dds.nvinfo(file)
|
|
format = info["format"]
|
|
alpha = dds.alpha(file)
|
|
|
|
if format == "DXT1":
|
|
pass
|
|
elif format == "DXT5":
|
|
if alpha > 254:
|
|
print(f'[{argv}]: Image is DXT5 but has no alpha channel')
|
|
else:
|
|
print(f'[{argv}]: incompatible format') |