33 lines
1009 B
Python
33 lines
1009 B
Python
import subprocess
|
|
import re
|
|
|
|
def alpha(file):
|
|
result = subprocess.run([convertcmd, file, "-resize", "1x1", "-format", "%[fx:int(255*a+.5)]", "info:-"], capture_output=True)
|
|
result.check_returncode()
|
|
return int(result.stdout)
|
|
|
|
def flip(file, output):
|
|
result = subprocess.run([convertcmd, '-flip', file, output], capture_output=True)
|
|
result.check_returncode()
|
|
|
|
def nvcompress(format, file, output, mips = True):
|
|
args = [format]
|
|
if not mips:
|
|
args.append('-nomips')
|
|
|
|
result = subprocess.run([compresscmd] + args + [file, output], capture_output=True)
|
|
result.check_returncode()
|
|
|
|
def nvdecompress(file, output):
|
|
result = subprocess.run([decompresscmd, file, output], capture_output=True)
|
|
result.check_returncode()
|
|
|
|
def nvinfo(file):
|
|
result = subprocess.run([infocmd, file], capture_output=True)
|
|
result.check_returncode()
|
|
|
|
info = {
|
|
"format": re.search(r"FourCC: '(.{4})'", str(result.stdout)).group(1)
|
|
}
|
|
|
|
return info |