29 lines
921 B
Python
29 lines
921 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):
|
|
result = subprocess.run([compresscmd, format, 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 |